Unix Technical Forum

Re: select ... from sysprocesses

This is a discussion on Re: select ... from sysprocesses within the SQL Server forums, part of the Microsoft SQL Server category; --> db dude (db_guy_2002@yahoo.com) writes: > When I run the query "select * from sysprocesses", I see a field "cmd" ...


Go Back   Unix Technical Forum > Database Server Software > Microsoft SQL Server > SQL Server

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-28-2008, 06:24 PM
Erland Sommarskog
 
Posts: n/a
Default Re: select ... from sysprocesses

db dude (db_guy_2002@yahoo.com) writes:
> 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@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
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
Trackbacks are On
Pingbacks are On
Refbacks are On
Forum Jump


All times are GMT. The time now is 12:49 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.2.0
www.UnixAdminTalk.com