Skip to content

Instantly share code, notes, and snippets.

@cbertolasio
Created February 15, 2018 23:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cbertolasio/632c5f3e0272afe7560203ef741a17b8 to your computer and use it in GitHub Desktop.
Save cbertolasio/632c5f3e0272afe7560203ef741a17b8 to your computer and use it in GitHub Desktop.
gets the last sql command issued by a spid
sp_who2
DECLARE @sqltext VARBINARY(128)
SELECT @sqltext = sql_handle
FROM sys.sysprocesses
WHERE spid = 62
SELECT TEXT
FROM sys.dm_exec_sql_text(@sqltext)
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment