In Sql Server 2005 and 2008 you can script the stored procedure in Management Studio by right clicking on Store Procedure name and clicking on “Script Store Procedure as” and then “Create To”.
But if you want to script all the Stored Procedures in the database programmatically, then here is the simple T-SQL query for it -
To script All the Stored Procedures in the Database :
SELECT O.Name as ProcName |
If the Stored Procedure is created with ENCRYPTION option then you will get the NULL in the definition column.
Similarly,
To script All the Views in the Database :
SELECT O.Name as ProcName |
To script All the Functions in the Database :
SELECT O.Name as ProcName |
For scripting all Triggers small modification is required, instead of sys.objects I joined the sys.triggers with sys.sql_modules.
To script All the Triggers in the Database :
SELECT O.Name as ProcName |
Mangal Pardeshi
SQL MVP
Can u please suggest me on how to get all the stored procedures scripts of a database at a time in SQL 2000
ReplyDeleteHi,
ReplyDeleteYou can generate the Script from Enterprise Manager. Just right click on the Database name >> All tasks >> Generate SQL Scripts.
There select stored procedures.
HTH
Mangal
How do I generate the script to a file?
ReplyDeleteI want to generate the scripts and check them into to sourcesafe.
maybe it can help you!
Deletehttp://www.kodyaz.com/articles/sql-server-script-database-by-sql-2008-script-wizard.aspx