sql server2005存储过程解密问题
sql server 2005 的存储过程。从网上下载了个可以说是最全的。但是在查看一内容多的存储过程还是不行。老一些的提示
消息 8152,级别 16,状态 10,过程 jm,第 8 行
将截断字符串或二进制数据。
用下面的这个结果是什么都没有,不知那位高手朋友帮忙看看,谢谢!·
create PROCEDURE [dbo].[sp__windbi$decrypt]
(@procedure sysname = NULL, @revfl int = 1)
AS
/*
王成辉翻译整理,转贴请注明出自微软BI开拓者www.windbi.com
目前这个存储过程只能解密存储过程,至于解密函数、触发器、视图的存储过程本网站会进一步关注,调用形式为:
exec dbo.sp__windbi$decrypt @procedure,0
如果第二个参数使用1的话,会给出该存储过程的一些提示。
--版本3.0 修正存储过程过长引起的问题
*/
SET NOCOUNT ON
IF @revfl = 1
BEGIN
PRINT '警告:该存储过程会删除并重建原始的存储过程。'
PRINT ' 在运行该存储过程之前确保你的数据库有一个备份。'
PRINT ' 该存储过程通常应该运行在产品环境的一个备份的非产品环境下。'
PRINT ' 为了运行这个存储过程,将参数@refl的值更改为0。'
RETURN 0
END
DECLARE @intProcSpace bigint, @t bigint, @maxColID smallint,@procNameLength int
select @maxColID = max(subobjid) FROM
sys.sysobjvalues WHERE objid = object_id(@procedure)
--select @maxColID as 'Rows in sys.sysobjvalues'
select @procNameLength = datalength(@procedure) + 29
DECLARE @real_01 nvarchar(max)
DECLARE @fake_01 nvarchar(max)
DECLARE @fake_encrypt_01 nvarchar(max)
DECLARE @real_decrypt_01 nvarchar(max),@real_decrypt_01a nvarchar(max)
declare @objtype varchar(2),@ParentName nvarchar(max)
select @real_decrypt_01a = ''
--提取对象的类型如是存储过程还是函数,如果是触发器,还要得到其父对象的名称
select @objtype=type,@parentname=object_name(parent_object_id)
from sys.objects where [object_id]=object_id(@procedure)
-- 从sys.sysobjvalues里提出加密的imageval记录
SET @real_01=(SELECT top 1 imageval FROM sys.sysobjvalues WHERE objid =
object_id(@procedure) and valclass = 1 order by subobjid)
--创建一个临时表
create table #output ( [ident] [int] IDENTITY (1, 1) NOT NULL ,
[real_decrypt] NVARCHAR(MAX) )
--开始一个事务,稍后回滚
BEGIN TRAN
--更改原始的存储过程,用短横线替换
if @objtype='P'
SET @fake_01='ALTER PROCEDURE '+ @procedure +' WITH ENCRYPTION AS
'+REPLICATE(cast('-'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)
else if @objtype='FN'
SET @fake_01='ALTER FUNCTION '+ @procedure +'() RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/ END'
else if @objtype='V'
SET @fake_01='ALTER view '+ @procedure +' WITH ENCRYPTION AS select 1 as col
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/'
else if @objtype='TR'
SET @fake_01='ALTER trigger '+ @procedure +' ON '+@parentname+'WITH ENCRYPTION AFTER INSERT AS RAISERROR (''N'',16,10)
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/'
EXECUTE (@fake_01)
--从sys.sysobjvalues里提出加密的假的
SET @fake_encrypt_01=(SELECT top 1 imageval FROM sys.sysobjvalues WHERE objid =
object_id(@procedure) and valclass = 1 order by subobjid )
if @objtype='P'
SET @fake_01='Create PROCEDURE '+ @procedure +' WITH ENCRYPTION AS
'+REPLICATE(cast('-'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)
else if @objtype='FN'
SET @fake_01='CREATE FUNCTION '+ @procedure +'() RETURNS INT WITH ENCRYPTION AS BEGIN RETURN 1
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/ END'
else if @objtype='V'
SET @fake_01='Create view '+ @procedure +' WITH ENCRYPTION AS select 1 as col
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/'
else if @objtype='TR'
SET @fake_01='Create trigger '+ @procedure +' ON '+@parentname+'WITH ENCRYPTION AFTER INSERT AS RAISERROR (''N'',16,10)
/*'+REPLICATE(cast('*'as nvarchar(max)), datalength(@real_01) /2 - @procNameLength)+'*/'
--开始计数
SET @intPr