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')

asked 28 May '13, 09:07

Audun's gravatar image

Audun
1266813
accept rate: 0%


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 ...

permanent link

answered 30 May '13, 12:05

Jeff%20Albion's gravatar image

Jeff Albion
10.7k171174
accept rate: 24%

edited 30 May '13, 12:11

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×106
×36

question asked: 28 May '13, 09:07

question was seen: 676 times

last updated: 30 May '13, 12:11