SQL 函数\存储过程\视图加密及解密
-- 加密存储过程
CREATE PROCEDURE MTB_WithEncryption WITH ENCRYPTION
AS
BEGIN
-- START: Properitary Business Logic
--
--
--
--
-- END: Properitary Business Logic
SELECT * FROM dbo.Table_1
SELECT 'From ENCRYPTED Stored Procedure'
END
GO
-- 常规存储过程
CREATE PROCEDURE MTB_NoEncryption
AS
BEGIN
SELECT 'From MTB_NoEncryption'
END
GO
-- 函数
CREATE FUNCTION MTB_fnNoEncryption
(
@value varchar(50)
)
RETURNS varchar(50)
AS
BEGIN
RETURN @value + ' - From Regular Function'
END
GO
-- 加密函数
CREATE FUNCTION MTB_fnWithEncryption
(
@value varchar(50)
)
RETURNS varchar(50) WITH ENCRYPTION
AS
BEGIN
-- START: Properitary Business Logic
--
--
--
--
-- END: Properitary Business Logic
RETURN @value + ' - From ENCRYPTED Function'
END
GO
-- 参考网址:https://www.mytecbits.com/microsoft/sql-server/encrypting-stored-procedure
-- 解密方法:有两种
-- 1、使用脚本
-- 2、使用解密软件工具
-- 参考网址:https://sqljunkieshare.com/2012/03/07/decrypting-encrypted-stored-procedures-views-functions-in-sql-server-20052008-r2/