读书人

【怎样获取存储过程源代码】?该如何处

发布时间: 2012-09-13 09:51:52 作者: rapoo

【怎样获取存储过程源代码】???????????????????????????????????????
以下代码,虽然能获取到,但是获取的不完整,貌似只能获取前几行的定义,怎样获取完整的啊??
是用代码获取,不是用工具哦。。


SQL code
SET QUOTED_IDENTIFIER ON GO SET ANSI_NULLS ON GO -- GetContentByProcedureName '[dbo].[存储过程名]' Create procedure GetContentByProcedureName (@ProcedureName nvarchar(500)) as if exists (select * from dbo.syscomments where id=object_id(N''+@ProcedureName+'')) select c.text, c.encrypted, c.number, xtype=convert(nchar(2), o.xtype), datalength(c.text), convert(varbinary(8000), c.text), 0 from dbo.syscomments c, dbo.sysobjects o where o.id = c.id and c.id = object_id(N''+@ProcedureName+'') order by c.number, c.colid option(robust plan) GO SET QUOTED_IDENTIFIER OFF GO SET ANSI_NULLS ON GOdeclare @ProcedureName nvarchar(500);set @ProcedureName = 'sp_addalias';exec GetContentByProcedureName @ProcedureName--select @ProcedureName


[解决办法]
sp_helptext @ProcedureName
[解决办法]
SQL code
sp_helptext ProcedureName
[解决办法]
SQL code
select name from sys.procedures--orselect name from sysobjects where type='P'
[解决办法]
方法1:
SQL code
select 'sp_helptext '+name from sysobjects where type='P'
[解决办法]
探讨

方法1:SQL code
select 'sp_helptext '+name from sysobjects where type='P'

方法2:【数据库】→指定数据库,右键→【任务】→【生成脚本】,剩下的你应该懂的。

上面方法只用于对用户存储过程,且未被加密。

读书人网 >SQL Server

热点推荐