Determining what a SQL Server connection is doing
Quick note here describing how to find out what a connection to a Microsoft SQL Server is doing. First you need to find the connection.
Display current connections
Use the sp_who2 stored procedure to find the current connections. Use the following information to determine the connection of interest.
SPID- The ID of the connection. You will need this in the next step.Status- Typically this will be RUNNABLE, but occasionally it will be sleeping or SUSPENDED.Login- Typically the user who’s connection you are investigating (e.g. your own).HostName- The name of the computer making the connection.DBName- The database to which the connection is made.Command- The command being executed. Only displays the high-level command (e.g.SELECT INTO,DELETE, etc.).
Note that you can also specify an SPID to the sp_who2 stored procedure to get information about a specific connection.
Display the command
Use the following command to display the full SQL command being executed (where 53 is the SPID for the connection).
dbcc inputbuffer(53)
This command will display a result row with three columns:
EventTypeParametersEventInfo
EventInfo contains the information you are looking for.




Leave a Reply