dbTalk Databases Forums  

Re: select ... from sysprocesses

comp.databases.ms-sqlserver comp.databases.ms-sqlserver


Discuss Re: select ... from sysprocesses in the comp.databases.ms-sqlserver forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Anith Sen
 
Posts: n/a

Default Re: select ... from sysprocesses - 08-06-2003 , 03:01 PM






Take a peek at the system function fn_get_sql (SQL 2000, sp3) in SQL Server
Books Online.

--
- Anith
( Please reply to newsgroups only )



Reply With Quote
  #2  
Old   
Erland Sommarskog
 
Posts: n/a

Default Re: select ... from sysprocesses - 08-06-2003 , 04:35 PM






db dude (db_guy_2002 (AT) yahoo (DOT) com) writes:
Quote:
When I run the query "select * from sysprocesses", I see a field "cmd"
that contains some information about what kind of sql statement was
executed. But it does not contain the entire text of the sql query
that was run. Is there anyway, I can get the text for sql statement
also besides all the other information (such as spid, uid, dbid,
hostname, programname, etc).
There are two ways to get this information. DBCC INPUTBUFFER(spid)
gives you most recently submitted command from the client. The other
is fn_get_sql that Anith mentioned. This function was added to SQL2000
in SP3. You get the handle column from sysprocesses and passes it
to fn_get_sql, which returns you the complete text of the currently
executing scope. That is, if the client invoked stored procedure A,
which invoked stored procedure B, which inserted data into a table
with a trigger, and the trigger is currently executing, you get the
text of the trigger. The columns stmt_start and stmt_end helps you
to get the exact current statement.

--
Erland Sommarskog, SQL Server MVP, sommar (AT) algonet (DOT) se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.