我在GUI以外的Sql中生成脚本 [英] I generate Scripts in Sql other than GUI

查看:105
本文介绍了我在GUI以外的Sql中生成脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


如果我们从Sql server中的GUI生成脚本,我们将能够按原样获取存储过程(包括结构).
但是,当我们考虑使用"sys.sql_modules"时,我们将所有存储过程放在一行中,如果脚本中有任何一行注释,则以下所有代码都将被注释.因此,我们需要重新排列脚本.
在这种情况下,我们不能采用脚本直接移动到生产环境.
除了GUI,任何人都可以建议其他方法来生成脚本.

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.

推荐答案

您可以使用系统存储过程 sp_helptext 或系统函数 OBJECT_DEFINITION
示例:
You can use system stored procedure sp_helptext or system function OBJECT_DEFINITION
Example:
SP_HELPTEXT YourSPName
SELECT OBJECT_DEFINITION (OBJECT_ID(N'dbo.YourSPName'));



参考:
查看存储过程的定义 [



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

Hope, it helps :)


这篇关于我在GUI以外的Sql中生成脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆