如何导出存储过程的内容?

cra*_*her 0 stored-procedures export sql-server-2005

如何使用SQL语句导出存储过程的内容?

Joh*_*yre 7

如果通过'Content'谈论代码,请查看sp_helptext()

http://msdn.microsoft.com/en-us/library/ms176112.aspx

这是基于旧PUBS示例数据库的示例

USE pubs;
GO
EXEC sp_helptext 'pubs.dbo.byroyalty';
GO
Run Code Online (Sandbox Code Playgroud)

以下是结果

Text                                                                                      --------
CREATE PROCEDURE byroyalty @percentage int
AS
select au_id from titleauthor
where titleauthor.royaltyper = @percentage
Run Code Online (Sandbox Code Playgroud)

但是,如果用"内容"表示结果 ; 您可以使用"结果到文件..."设置运行proc,或者"结果在网格中"并右键单击网格,然后执行"另存为..."