Output text in a stored procedure using SQL Server
Is it possible to output the text (contents) in a stored procedure using a query? I want to have a query that I can run and just input the name of the stored proc instead of navigating to it.
There are literally hundreds of stored procs I have to navigate to, right click and select Modify and I would like an easier way to see the contents of the stored proc.
I am using SQL Server 2005.
Maybe something similar to:
SELECT *
FROM sys.proce开发者_StackOverflow社区dures
WHERE name = 'stored_procedure_name'
There are many ways to do that, You can try one of the following:
EXEC sp_helptext 'YourProcedure'
Which gives you the one row per line of the stored procedure, Or
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('YourProcedure')
Which gives you a single row with all of the stored procedure definition.
精彩评论