The forum will be unavailable for maintenance at some point from Friday, April 13 at 19:00 EDT until Sunday, April 15 at 23:59 EDT. Downtime will be minimized but the exact timing is unknown.

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?


asked 28 May '13, 09:07

Audun's gravatar image

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 28 May '13, 09:07

question was seen: 811 times

last updated: 30 May '13, 12:11