打印本文 打印本文 关闭窗口 关闭窗口
sqlserver 存储过程、存储函数的加密、解密
作者:武汉SEO闵涛  文章来源:敏韬网  点击数7908  更新时间:2007/11/14 13:08:52  文章录入:mintao  责任编辑:mintao
begin

declare @parent_obj varchar(255),@tr_parent_xtype varchar(10)

select @parent_obj=parent_obj from sysobjects where id=object_id(@objectName)

select @tr_parent_xtype=xtype from sysobjects where id=@parent_obj

if @tr_parent_xtype=''''V''''

begin

set @sql1=''''ALTER TRIGGER ''''+@objectname+'''' ON ''''+OBJECT_NAME(@parentid)+'''' WITH ENCRYPTION INSTERD OF INSERT AS PRINT 1 ''''

end

else

begin

set @sql1=''''ALTER TRIGGER ''''+@objectname+'''' ON ''''+OBJECT_NAME(@parentid)+'''' WITH ENCRYPTION FOR INSERT AS PRINT 1 ''''

end

 

end

if @type=''''FN'''' or @type=''''TF'''' or @type=''''IF''''

set @sql1=(case @type when ''''TF'''' then

''''ALTER FUNCTION ''''+ @objectName+''''(@a char(1)) returns @b table(a varchar(10)) with encryption as begin insert @b select @a return end ''''

when ''''FN'''' then

''''ALTER FUNCTION ''''+ @objectName+''''(@a char(1)) returns char(1) with encryption as begin return @a end''''

when ''''IF'''' then

''''ALTER FUNCTION ''''+ @objectName+''''(@a char(1)) returns table with encryption as return select @a as a''''

end)

 

if @type=''''V''''

set @sql1=''''ALTER VIEW ''''+@objectname+'''' WITH ENCRYPTION AS SELECT 1 as f''''

 

set @q=len(@sql1)

set @sql1=@sql1+REPLICATE(''''-'''',4000-@q)

select @sql2=REPLICATE(''''-'''',8000)

set @sql3=''''exec(@sql1''''

select @colid=max(colid) from #temp

上一页  [1] [2] [3] [4] [5] [6] [7] [8]  下一页

打印本文 打印本文 关闭窗口 关闭窗口