Click here to Skip to main content
16,018,417 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
If we generate script from GUI in Sql server we are able to get Stored Procedures as they are (including structure).
But when we consider using "sys.sql_modules" we get all the stored procedure in a single line and if there is any single line comments in the script all the following code is being commented.So we need to rearrange the script.
In this case we can not take script to move to production environment directly.
Can any one suggest some other way to generate script other than GUI. so that We can get the scripts fast.
Posted

1 solution

You can use system stored procedure sp_helptext or system function OBJECT_DEFINITION
Example:
SQL
SP_HELPTEXT YourSPName
SELECT OBJECT_DEFINITION (OBJECT_ID(N'dbo.YourSPName'));


Reference:
View the Definition of a Stored Procedure[^]

Hope, it helps :)
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900