·天新网首页·加入收藏·设为首页·网站导航
数码笔记本手机摄像机相机MP3MP4GPS
硬件台式机网络服务器主板CPU硬盘显卡
办公投影打印传真
家电电视影院空调
游戏网游单机动漫
汽车新车购车试驾
下载驱动源码
学院开发设计
考试公务员高考考研
业界互联网通信探索
SQL Server存储函数的加密解密
http://www.21tx.com 2005年08月19日 软考资讯网

上一页 1 2

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

  set @sql3='exec(@sql1'

  select @colid=max(colid) from #temp where number=@k

  set @n=1

  while @n<=CEILING(1.0*(@colid-1)/2) and len(@sQL3)<=3996

  begin

  set @sql3=@sql3+'+@'

  set @n=@n+1

  end

  set @sql3=@sql3+')'

  exec sp_executesql @sql3,N'@sql1 nvarchar(4000),@ varchar(8000)',@sql1=@sql1,@=@sql2

  end

  set @k=@k+1

  end

  set @k=0

  while @k<=@number

  begin

  if exists(select 1 from syscomments where id=object_id(@objectname) and number=@k)

  begin

  select @colid=max(colid) from #temp where number=@k

  set @n=1

  while @n<=@colid

  begin

  select @OrigSpText1=ctext,@encrypted=encrypted,@status=status FROM #temp WHERE colid=@n and number=@k

  SET @OrigSpText3=(SELECT ctext FROM syscomments WHERE id=object_id(@objectName) and colid=@n and number=@k)

  if @n=1

  begin

  if @type='P'

  SET @OrigSpText2=(case when @number>1 then 'CREATE PROCEDURE '+ @objectName +';'+rtrim(@k)+' WITH ENCRYPTION AS '

  else 'CREATE PROCEDURE '+ @objectName +' WITH ENCRYPTION AS '

  end)

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

  SET @OrigSpText2=(case @type when 'TF' then

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

  when 'FN' then

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

  when 'IF' then

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

  end)

  if @type='TR'

  begin

  if @tr_parent_xtype='V'

  begin

  set @OrigSpText2='CREATE TRIGGER '+@objectname+' ON '+OBJECT_NAME(@parentid)+' WITH ENCRYPTION INSTEAD OF INSERT AS PRINT 1 '

  end

  else

  begin

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

  end

  end

  if @type='V'

  set @OrigSpText2='CREATE VIEW '+@objectname+' WITH ENCRYPTION AS SELECT 1 as f'

  set @q=4000-len(@OrigSpText2)

  set @OrigSpText2=@OrigSpText2+REPLICATE('-',@q)

  end

  else

  begin

  SET @OrigSpText2=REPLICATE('-', 4000)

  end

  SET @i=1

  SET @resultsp = replicate(N'A', (datalength(@OrigSpText1) / 2))

  WHILE @i<=datalength(@OrigSpText1)/2

  BEGIN

  SET @resultsp = stuff(@resultsp, @i, 1, NCHAR(UNICODE(substring(@OrigSpText1, @i, 1)) ^

  (UNICODE(substring(@OrigSpText2, @i, 1)) ^

  UNICODE(substring(@OrigSpText3, @i, 1)))))

  SET @i=@i+1

  END

  set @orgvarbin=cast(@OrigSpText1 as varbinary(8000))

  set @resultsp=(case when @encrypted=1

  then @resultsp

  else convert(nvarchar(4000),case when @status&2=2 then uncompress(@orgvarbin) else @orgvarbin end)

  end)

  print @resultsp

  set @n=@n+1

  end

  end

  set @k=@k+1

  end

  drop table #temp

  rollback tran

  end


  

上一篇: 信息处理技术员考试大纲
下一篇: 电子商务技术员考试大纲

上一页 1 2

关于我们 | 联系我们 | 加入我们 | 广告服务 | 投诉意见 | 网站导航
Copyright © 2000-2011 21tx.com, All Rights Reserved.
晨新科技 版权所有 Created by TXSite.net