用于打开存储过程并在 SQL Server 中读取它的 SQL 代码
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/6129815/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
SQL code to open a stored procedure and read it in SQL Server
提问by Marcos Buarque
I am using an interface that only allows me to use SQL commands. The database is SQL Server. Right now I need to open a stored procedure and read what is inside of it. What is the SQL command to open a stored procedure for reading? Thank you.
我使用的接口只允许我使用 SQL 命令。数据库是 SQL Server。现在我需要打开一个存储过程并阅读其中的内容。打开存储过程进行读取的SQL命令是什么?谢谢你。
回答by Joe Stefanelli
SELECT definition
FROM sys.sql_modules
WHERE object_id = OBJECT_ID('YourSchemaName.YourProcedureName')
回答by Fosco
sp_helptext 'dbo.myStoredProc'
回答by gbn
SELECT OBJECT_DEFINITION(OBJECT_ID('dbo.myStoredProc'))
Note: subject to Metadata Visibilityand VIEW DEFINITIONrights
回答by garnertb
SELECT TEXT
FROM syscomments
WHERE id = (SELECT id FROM sysobjects WHERE name = '<NAME>')
ORDER BY colid