When examining the contents of sys.sysprocesses one of the very last columns in the table is labelled as the sql_handle. This is a very useful hex number which represents the T-SQL which was run during a process. We can use the inline table value expression dm_exec_sql_text() to translate this hex into text showing what T-SQL was run.

Very simply,

select *
from sys .dm_exec_sql_text( <<sql_handle goes here>> )

Its also possible to use dbcc inputbuffer with the spid from a process,

dbcc inputbuffer (<<spid goes here>>)

This will also return the T-SQL run but there is a limit to how many characters inputbuffer can display. If the command is long the end will be cut off.