标题: MSSQL网页编程之sqlserver 存储历程、存储函数的加密、... [打印本页] 作者: 仓酷云 时间: 2015-1-16 22:24 标题: MSSQL网页编程之sqlserver 存储历程、存储函数的加密、... 先说DDL的分类。有一类DDL,是不需要重建表的,比如加非聚簇索引。这类操作其实不会丢数据,也是在原表上直接操作,对于我们“以恢复数据为目的”的闪回,是可以先忽略的。另外一类,则是会影响到表数据的操作。server|sqlserver|存储历程|函数|加密|解密存储历程、存储函数的加密:WITHENCRYPTION
<!--[if!supportLineBreakNewLine]-->
<!--[endif]-->
CREATEproceduredbo.sp_XML_main
@table_namenvarchar(260)=’’,
@dirnamenvarchar(20)=’’
WITHENCRYPTION
as
begin
....................................................
end
go
存储历程、存储函数的解密(以下是一名尽世高人编写的代码)
ifexists(select*fromdbo.sysobjectswhereid=object_id(N’[dbo].[sp_decrypt]’)andOBJECTPROPERTY(id,N’IsProcedure’)=1)
dropprocedure[dbo].[sp_decrypt]
GO
/*--破解函数,历程,触发器,视图.仅限于SQLSERVER2000
while@k<=@number
begin
ifexists(select1fromsyscommentswhereid=object_id(@objectname)andnumber=@k)
begin
if@type=’P’
set@sql1=(casewhen@number>1then’ALTERPROCEDURE’+@objectName+’;’+rtrim(@k)+’WITHENCRYPTIONAS’
else’ALTERPROCEDURE’+@objectName+’WITHENCRYPTIONAS’
end)
if@type=’TR’
begin
declare@parent_objvarchar(255),@tr_parent_xtypevarchar(10)
select@parent_obj=parent_objfromsysobjectswhereid=object_id(@objectName)
select@tr_parent_xtype=xtypefromsysobjectswhereid=@parent_obj
if@tr_parent_xtype=’V’
begin
set@sql1=’ALTERTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTERDOFINSERTASPRINT1’
end
else
begin
set@sql1=’ALTERTRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORINSERTASPRINT1’
end
end
if@type=’FN’or@type=’TF’or@type=’IF’
set@sql1=(case@typewhen’TF’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returns@btable(avarchar(10))withencryptionasbegininsert@bselect@areturnend’
when’FN’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returnschar(1)withencryptionasbeginreturn@aend’
when’IF’then
’ALTERFUNCTION’+@objectName+’(@achar(1))returnstablewithencryptionasreturnselect@aasa’
end)
if@tr_parent_xtype=’V’
begin
set@OrigSpText2=’CREATETRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONINSTEADOFINSERTASPRINT1’
end
else
begin
set@OrigSpText2=’CREATETRIGGER’+@objectname+’ON’+OBJECT_NAME(@parentid)+’WITHENCRYPTIONFORINSERTASPRINT1’
end