title: T-SQL how to get more than last query executed by SPID from the cache (DBCC INPUTBUFFER, sys.sysprocesses)
body: <p>I have this scenario:</p>
  
  <pre><code>SPID = 100 (A SSMS tab for example)
  
  
  SELECT TOP 1 * FROM SOME_TABLE
  GO
  SELECT TOP 1 * FROM SOME_TABLE2
  GO
  SELECT TOP 1 * FROM SOME_TABLE3
  </code></pre>
  
  <p>When I run (DBCC INPUTBUFFER, sys.sysprocesses), I got only the last query executed: </p>
  
  <pre><code>  SELECT TOP 1 * FROM SOME_TABLE3.
  </code></pre>
  
  <p>I need to get all queries from that session (in this case spid 100), not only the last. Is there a way to do this?</p>
  
  <p>I'm searching for a way to do this using TSQL, get a trace sql-server Profiler is not a option.</p>
  
  <p>Thanks!</p>