How to get parameter values for dm_exec_sql_text

Posted by Ted Elliott on Stack Overflow See other posts from Stack Overflow or by Ted Elliott
Published on 2010-03-24T16:04:49Z Indexed on 2010/03/24 19:03 UTC
Read the original article Hit count: 329

I'm running the following statement to see what queries are executing in sql server:

select *
from sys.dm_exec_requests r
cross apply sys.dm_exec_sql_text(r.sql_handle)
where r.database_id = DB_ID('<dbname>')

The sql text that comes back is parameterized:

(@Parm0 int) select * from foo where foo_id = @Parm0

Is there any way to get the values for the parameters that the statement is using? Say by joining to another table perhaps?

© Stack Overflow or respective owner

Related posts about sql-server

Related posts about sql-server-2005