存储过程加密

来源:互联网 发布:html广告源码 编辑:程序博客网 时间:2024/05/16 08:45

 

DECLARE @sp_name nvarchar(400)

DECLARE @sp_content nvarchar(2000)

DECLARE @asbegin int

declare @now datetime

select @now = getdate()

DECLARE sp_cursor CURSOR FOR 

SELECT object_name(id)

FROM sysobjects

WHERE xtype = 'P' 

AND type = 'P' 

AND crdate < @now

AND OBJECTPROPERTY(id, 'IsMSShipped')=0

OPEN sp_cursor

FETCH NEXT FROM sp_cursor 

INTO @sp_name

WHILE @@FETCH_STATUS = 0

BEGIN

SELECT @sp_content = text FROM syscomments WHERE id = OBJECT_ID(@sp_name) 

SELECT @asbegin = PATINDEX ( '%AS' + char(13) + '%', @sp_content) 

SELECT @sp_content = SUBSTRING(@sp_content, 1, @asbegin - 1) 

+ ' WITH ENCRYPTION AS'

+ SUBSTRING (@sp_content, @asbegin+2, LEN(@sp_content))

SELECT @sp_name = 'DROP PROCEDURE [' + @sp_name + ']'

EXEC sp_executesql @sp_name 

EXEC sp_executesql @sp_content

FETCH NEXT FROM sp_cursor 

INTO @sp_name

END

CLOSE sp_cursor 

DEALLOCATE sp_cursor

 

原创粉丝点击