Today we have an alert from one of the client server about blocking, I have immediately start looking at it using below statement
SELECT * FROM MASTER..SYSPROCESSES WHERE BLOCKED != 0
- Using Profiler
- using function – ::fn_get_sql(@SQLHandle)
-- Variable that will store the SQLHandle
DECLARE @SQLHandle BINARY(20)
-- Variable that will pass on the culprit SPID
DECLARE @SPID INT
-- value for culprit SPID
SET @SPID = 52
-- this will give you the SQLHandle for the culprit SPID
SELECT @SQLHandle = SQL_HANDLE
FROM MASTER..SYSPROCESSES
WHERE SPID = @SPID
-- this statement will give you the SQL Statement for culprit SPID
SELECT [TEXT] FROM ::FN_GET_SQL(@SQLHandle)
You must be thinking why I have used this function instead sys.dm_exec_sql_text? Any guess??
Yes, you are right, customer is still using SQL server 2000 {Winking smile}
BTW, if you happened to come across something relating but on SQL Server 2005 or SQL Server 2008 and greater I have a reference script for you
Yes, you are right, customer is still using SQL server 2000 {Winking smile}
BTW, if you happened to come across something relating but on SQL Server 2005 or SQL Server 2008 and greater I have a reference script for you
--Hemantgiri S. Goswami (http://www.sql-server-citation.com )
0 comments:
Post a Comment
I appreciate your time, thanks for posting your comment. I will review and reply to your comment as soon as I can.
Thank you
Hemantgiri