Showing posts with label manager. Show all posts
Showing posts with label manager. Show all posts

Friday, March 23, 2012

Finding a Deadlock

Are there any type of utilities on SQL Enerprise manager that can help me
locate a deadlock?The two most useful utilities are DBCC TRACEON and SQL Profiler.
SQL Profiler has Lock:Deadlock & Lock:Deadlock Chain events which are useful
in interpreting deadlocks, but issuing the command: "DBCC TRACEON (3605,
1204, -1)" establishes a trace within SQL Server which writes detailed
deadlock debug info to the SQL Server Error Log.
SQL Profiler is a separate GUI tool from the EM, but can be launched from
the EM's tools menu. DBCC TRACEON is a command - you issue it from the Query
Analyser, but it writes output to the SQL Error Logs which can in turn be
read from the EM (under the Management node).
HTH
Regards,
Greg Linwood
SQL Server MVP
"MFRASER" <mfraser@.henwoodenergy.com> wrote in message
news:OKugdAm%23DHA.1844@.TK2MSFTNGP11.phx.gbl...
> Are there any type of utilities on SQL Enerprise manager that can help me
> locate a deadlock?
>|||Greg's advice is good. I would add, check out BOL for information about interpretting the output of trace flag 1204. The main thing is that it will identify the proc or SQL code which causes the deadlock and the resource that is deadlocked (row, page, key etc)
Cheers

Finding a Deadlock

Are there any type of utilities on SQL Enerprise manager that can help me
locate a deadlock?The two most useful utilities are DBCC TRACEON and SQL Profiler.
SQL Profiler has Lock:Deadlock & Lock:Deadlock Chain events which are useful
in interpreting deadlocks, but issuing the command: "DBCC TRACEON (3605,
1204, -1)" establishes a trace within SQL Server which writes detailed
deadlock debug info to the SQL Server Error Log.
SQL Profiler is a separate GUI tool from the EM, but can be launched from
the EM's tools menu. DBCC TRACEON is a command - you issue it from the Query
Analyser, but it writes output to the SQL Error Logs which can in turn be
read from the EM (under the Management node).
HTH
Regards,
Greg Linwood
SQL Server MVP
"MFRASER" <mfraser@.henwoodenergy.com> wrote in message
news:OKugdAm%23DHA.1844@.TK2MSFTNGP11.phx.gbl...
> Are there any type of utilities on SQL Enerprise manager that can help me
> locate a deadlock?
>|||Greg's advice is good. I would add, check out BOL for information about inte
rpretting the output of trace flag 1204. The main thing is that it will iden
tify the proc or SQL code which causes the deadlock and the resource that is
deadlocked (row, page, key
etc).
Cheers

Monday, March 19, 2012

Find tables in packages (SQL2000)

Hi!!!
We have about a houndred packages made with Enterprise Manager. Is
there any tool in SQL (or code) to find a certain table involved in a
package?
eg: I need to know in which packages is involved the table
cost_center...in other words which packages affects a determined table
Thanks for your help!
EzequielI'm affraid it is impossible
select packagedata from msdb..sysdtspackages
where name.....
<esapoznik@.gmail.com> wrote in message
news:1148477673.385381.177230@.38g2000cwa.googlegroups.com...
> Hi!!!
> We have about a houndred packages made with Enterprise Manager. Is
> there any tool in SQL (or code) to find a certain table involved in a
> package?
> eg: I need to know in which packages is involved the table
> cost_center...in other words which packages affects a determined table
> Thanks for your help!
> Ezequiel
>|||The only way I know of to search packages is to save them
out to Visual Basic files. You can then search the bas files
for the table name.
I've worked places where bas files for packages were kept
under source control which made it easy to find specific
objects.
-Sue
On 24 May 2006 06:34:33 -0700, esapoznik@.gmail.com wrote:

>Hi!!!
>We have about a houndred packages made with Enterprise Manager. Is
>there any tool in SQL (or code) to find a certain table involved in a
>package?
>eg: I need to know in which packages is involved the table
>cost_center...in other words which packages affects a determined table
>Thanks for your help!
>Ezequiel

Find tables in packages (SQL2000)

Hi!!!
We have about a houndred packages made with Enterprise Manager. Is
there any tool in SQL (or code) to find a certain table involved in a
package?
eg: I need to know in which packages is involved the table
cost_center...in other words which packages affects a determined table
Thanks for your help!
EzequielI'm affraid it is impossible
select packagedata from msdb..sysdtspackages
where name.....
<esapoznik@.gmail.com> wrote in message
news:1148477673.385381.177230@.38g2000cwa.googlegroups.com...
> Hi!!!
> We have about a houndred packages made with Enterprise Manager. Is
> there any tool in SQL (or code) to find a certain table involved in a
> package?
> eg: I need to know in which packages is involved the table
> cost_center...in other words which packages affects a determined table
> Thanks for your help!
> Ezequiel
>|||The only way I know of to search packages is to save them
out to Visual Basic files. You can then search the bas files
for the table name.
I've worked places where bas files for packages were kept
under source control which made it easy to find specific
objects.
-Sue
On 24 May 2006 06:34:33 -0700, esapoznik@.gmail.com wrote:
>Hi!!!
>We have about a houndred packages made with Enterprise Manager. Is
>there any tool in SQL (or code) to find a certain table involved in a
>package?
>eg: I need to know in which packages is involved the table
>cost_center...in other words which packages affects a determined table
>Thanks for your help!
>Ezequiel

Friday, March 9, 2012

Find open transactions

Is there an easy way (SQL Query or enterprise manager) to see if there is an open transaction pending?

yes, you can look into Management Activity monitor.
I do not know why you need this but remember that transaction is active as long as connection is active so if you look for not finalized transaction which were done in dropped connection it probably will not work.
I am not 100% sure about this but I found it somewhere.

Thanks

|||

I missed it when I looked before. FYI, I needed the information because I was debugging a long script that for some reason wasn't executing the statements after a certain line. I thought it might have been due to a transaction not being closed. But it was bad data preventing a unique index from being created.

Thanks for the answer.

Sunday, February 26, 2012

find all the employees under one manager (was "Need Help with Query")

I have an employee table with manager id and employee ids , i need to find all the employee ids for a manager id . Each employee can be a manager in turn . So I need to find all the employees under one manager and if any of the employee is in turn a manager , i need to find the employees under him as well .

The table structure is defined and i cannot edit it .

Please let me know if we could have a single query to do this .

Thank you
kishoreYou don't state what version of SQL Server you are using. New to SQL Server 2005 is Common Table Expressions (CTEs). An article on MSDN describes exactly what you are looking for: Recursive Queries Using Common Table Expressions (http://msdn2.microsoft.com/en-us/library/ms186243.aspx).

I'm afraid this is somewhat more tricky on SQL Server 2000.|||I need to support SQL server 2000 as well as 2005 ,also other Database like oracle , Db2 and sybase. Apart from Common Table Expression , is there any way i can do it .|||Well, the code won't be identical on the various platforms anyway. CTEs are supported on SQL Server 2005 and DB2, and perhaps the latest version of Sybase as well. It is a part of the SQL Standard since SQL:1999, so I would suggest using it where possible. For the rest you could create a temporary table, and use pretty much the same idea as in the CTE:

1. Insert all without a parent (top level)
2. Insert all whose having those in 1 as parent
3. Recursively insert all whose having their parent inserted, but are not inserted themselves yet.

I know, it's not very pretty code, but it works. Hope you got my idea :)|||SELECT e.known_as_and_surname
AS 'Employee'
,m.known_as_and_surname
AS 'Manager'
FROM employee AS e
LEFT OUTER JOIN employee AS m
ON m.employee_number = e.manager_number

Any good to you?
Self-join genius courtesy of Rudy at www.r937.com :beer:|||Any good to you?
That would be nice for 2 levels (manager and employee).
Triumph wants a top person's subordinates from 1, 2, x levels down.

If there is a fixed number of levels you can union that number (minus one) of select statements. If not, the temporary table that roac describes would be useful.

<edit>
Congratulations!|||roac approach would work i guess , but i was looking for a solution where in a single query would do the trick , but i guess its not going to be the case . I needed this solution to improve performance .|||no single query is ever going to work the same in sql server 2000, sql server 2005, oracle, db2, and sybase

if you are writing an application that "abstracts" the database layer, you are never going to achieve your result by trying to abstract the sql

instead, you need to abstract the information request, and write specific sql modules for each database -- in this case, CONNECT BY for oracle, CTEs for those that support it (it's part of the sql standard), a recursive call for other databases, etc.|||Thanks to all for helping me. I think i will do the recurvise calls using Java .|||Well good luck!

I'd love to see a solution to this if/when you get one ;)|||Thanks to all for helping me. I think i will do the recurvise calls using Java .
Ugh.
You would get excellent performance using the algorithm suggested by ROAC. I'd bet it would beat any recursive algorithm hands down. Recursion requires a separate call for each item in the hierarchy, while ROAC's suggestion only requires one call for each level in the hierarchy.|||I noticed the thread changed title... This simple query solves it as the title asks ;)
To find all the employees under ONE manager:

SELECT e.known_as_and_surname AS 'Employee'
FROM employee AS e
LEFT OUTER JOIN employee AS m
ON m.employee_number = e.manager_number
WHERE m.known_as_and_surname = '<InsertNameOfManager>'|||Without editing the layout of the table you're going to have difficulty getting a work around. If you know the max number of levels then you could hack it with a single query (based on rudy's example) :

SELECT
e1.name AS 'Lvl1',
e2.name AS 'Lvl2',
e3.name AS 'Lvl3',
e4.name AS 'Lvl4',
e5.name AS 'Lvl5',
FROM employee AS e1
LEFT OUTER JOIN employee AS e2 ON e2.employee_number = e1.manager_number
LEFT OUTER JOIN employee AS e3 ON e3.employee_number = e2.manager_number
LEFT OUTER JOIN employee AS e4 ON e4.employee_number = e3.manager_number
LEFT OUTER JOIN employee AS e5 ON e5.employee_number = e4.manager_number|||Queston : does MSSQL (2000) support recursive procedures?|||even if there is no maximum number of levels, you could still use the 4-way self-join to show just 4 levels of subtree, with links at each bottom level node if it has any further levels below it

and of course clicking on one of the links returns up 4 lower levels below that node, so in effect it "recurses" down the tree but it is the user driving the process 4 levels at a time

usually, any tree that is large enough to have "unlimited" levels is at the same time also too large to allow the complete display of the entire tree, so recursion would be neither practical nor desirable anyway

the way i see it ;)|||Rudy you have a point, however if this is for report generation and there are a lot of employees/managers then full recursion is going to be needed. Or you're planning on making a nice big tree heirarchy using some fancy graphical functionality then i suspect returning the full set will still be beneficial.