cancel
Showing results for 
Search instead for 
Did you mean: 

Can i get the query from a StoredProcedure and or triggers

Former Member
2,261

I have some stored procedures that i would like to know how gets called. Is it possible to get the query that gets executed from inside the procedure?

EX SELECT PROPERTY('QUERY')

Accepted Solutions (0)

Answers (1)

Answers (1)

jeff_albion
Product and Topic Expert
Product and Topic Expert

You can see the text of stored procedures by viewing the SYS.SYSPROCEDURE system view.

e.g. To see the text for a stored-procedure "sp_targetsp()":

SELECT proc_defn FROM SYS.SYSPROCEDURE WHERE proc_name = 'sp_targetsp'

You may also need to filter by "owner" if there are multiple stored procedures with the same name created by different database users.


If you'd like to see what is being executed inside of a stored procedure at runtime, you can monitor these statements using request-level logging:

dbsrv16 -zr SQL+PROCEDURES -zo rll.txt ...