Wednesday, February 15, 2012

Exporting Stored Procedures to a file

I have a need to export all of the stored procedures in a database to files on the server dirve. I know that this can be done through the management interface but I need a way to do it programatically. I need to have a script or stored proc that dumps all of the procedures to a defined location on disk. Does anyone know how this can be done?

Thanks!

You can use SQL-DMO (in SQL Server 2000) or SMO (in SQL Server 2005) to do this. Please take a look at the setup CD it contains sample solutions that you can use to familiarize with these APIs. You can also search in Books Online for samples.|||

There is an article with a stored procedure that does this at http://www.databasejournal.com/features/mssql/article.php/2205291

Also a slightly different approach to the same problem at http://www.databasejournal.com/features/mssql/article.php/3401081, though the first way is probably the one you want to use.

No comments:

Post a Comment