We all know the usage of sp_who2 command in SQL server, its life-saver when you need to know what's causing your query take longer time to execute or in other words who's blocking you r query.
But, SQL server has many in-built functions which lets you sneak a peek inside the sql server and we can use them to our advantage. One of them is
Using this function, we can see the last executed sql statement in that process id.
There are several ways to find out what is the latest run query from system table sys.sysprocesses.
DECLARE @sqltext VARBINARY(128)
SELECT @sqltext = sql_handle
WHERE spid = 61