Database Knowledge Base / MS SQL Server /
Email to friend
* Your name:
* Your email:
* Friend's email:
Comment:


Is there an easy way to loop through every stored procedure in a database and create a file containing all of the SP code?

By joining sysobject and syscomments table we can get your desired results,
run this query in Query Analyzer (with result in text mode)....
-----------------------------------------------------------------------------
SELECT dbo.syscomments.text, dbo.sysobjects.name
FROM dbo.syscomments INNER JOIN
dbo.sysobjects ON dbo.syscomments.id = dbo.sysobjects.id
WHERE (dbo.sysobjects.xtype = 'p')
-----------------------------------------------------------------------------



RSS