如何用sql语句导出存储过程的脚本

DieMan 2008-08-25 03:11:27
想写一个c#程序导出数据库中的存储过程脚本.不知道有有没相关的sql可以用?
...全文
239 5 打赏 收藏 转发到动态 举报
写回复
用AI写文章
5 条回复
切换为时间正序
请发表友善的回复…
发表回复
bwu851 2008-08-26
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 qizhi_t 的回复:]
select [text] from dbo.syscomments where id in (select [id] from sysobjects where type='p' and name=@name) @name的值就是你要查询的存储过程的名称
[/Quote]

这方法并不好, 因为text在syscomments里不能超过8K字节, 也就是说, 这样得不到很长的存储过程. --- 只显示前面一小段代码

一般偶都用:

sp_helptext 存储过程名
JYR520 2008-08-26
  • 打赏
  • 举报
回复
学习一下,支持
muzhenxing013 2008-08-26
  • 打赏
  • 举报
回复
select [text] from dbo.syscomments where id in (select [id] from sysobjects where type='p' and name=@name) @name的值就是你要查询的存储过程的名称
--------顶
lff642 2008-08-26
  • 打赏
  • 举报
回复
你可以把一楼的再改进一下.

加上使用游标并且封装成一个存储过程,就可以很好的列出所有的存储过程了.
qizhi_t 2008-08-26
  • 打赏
  • 举报
回复
select [text] from dbo.syscomments where id in (select [id] from sysobjects where type='p' and name=@name) @name的值就是你要查询的存储过程的名称

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧