Dynamic Management View:
sys.dm_exec_sql_text(sql_handle)
sql_handle SQL handle of the text to be looked up.
It retruns:SELECT T.TEXT, P.*
dbid - Database ID, you can get database name by using DB_Name(dbid) function.
Objectid - Object ID, you can get Object name by using Object_Name(objectid) funciton.
number - store procedures number if any
encrypted - if text is encrypted, it will have value 1
text - text of SQL query
Example:
FROM SYS.SYSPROCESSES P
OUTER APPLY SYS.DM_EXEC_SQL_TEXT(SQL_HANDLE) T
No comments:
Post a Comment