开发者

How to script a stored procedure from TSQL

开发者 https://www.devze.com 2023-04-08 04:40 出处:网络
I know there\'s a way to do this as I\'ve seen it done - I just can\'t remember how. I want开发者_StackOverflow中文版 to run a SQL command which will return the script to create the stored procedure

I know there's a way to do this as I've seen it done - I just can't remember how.

I want开发者_StackOverflow中文版 to run a SQL command which will return the script to create the stored procedure as a result.

How can I do this?


Try using sp_helptext command :

sp_helptext 'yourprocname'

or using object_definition :

SELECT OBJECT_DEFINITION(OBJECT_ID('yourprocname')) 


SELECT OBJECT_DEFINITION(OBJECT_ID('your_schema.your_procname'))

or

EXEC sp_helptext 'your_schema.your_procname'


In SQL Server Management Studio, right-click the proc in the Object Explorer window and choose Script Stored Procedure as ...then choose the operation (Create, Drop, etc.) you want to script.

0

精彩评论

暂无评论...
验证码 换一张
取 消