Search code examples
c#sql-serversql-server-2005stored-procedures

Simple way to programmatically get all stored procedures


Is there a way to get stored procedures from a SQL Server 2005 Express database using C#? I would like to export all of this data in the same manner that you can script it our using SQL Server Management Studio, without having to install the GUI.

I've seen some references to do thing via the PowerShell but in the end a C# console app is what I really want.

To clarify....

I'd like to script out the stored procedures. The list via the Select * from sys.procedures is helpful, but in the end I need to script out each of these.


Solution

  • Just read the output of SELECT NAME from SYS.PROCEDURES , then call EXEC sp_HelpText SPNAME for each stored procedure, you'll get a record set with one line of text per row.