T-SQL????????????????????
???????????? ???????[ 2013/1/17 10:03:03 ] ????????
?????????????伪????????????澹�????????????????????
?????????????????????????????WITH ENCRYPTION???????????????????????濉�???????????????????????????????????????????????????
????????????????????????????????????????????斜??妫�?????????????????
???????????????
--1????????????娲�????
USE AdventureWorks
GO
CREATE PROC test
WITH ENCRYPTION
AS
SELECT SUSER_SNAME() ??
USER_NAME()
GO
--2??????????????????????????????????EncryptByPassPhrase????????????????sys.sp_addextendedproperty?娲�???????????????????
USE AdventureWorks
GO
DECLARE @sql VARCHAR(MAX)
SET @sql = 'CREATE PROC Test WITH ENCRYPTION AS SELECT suer_sname()??user_name() GO'
--3?????????????????sql_variant????????
DECLARE @bsql SQL_VARIANT
SET @bsql = ( SELECT CONVERT(SQL_VARIANT?? ENCRYPTBYPASSPHRASE('P@ssw0rd'??
CONVERT(VARCHAR(MAX)?? @sql)))
)
--4????????????娲�?????????????校?
EXEC sys.sp_addextendedproperty @name = N'test????'?? @value = N'System.Byte[]'??
@level0type = N'SCHEMA'?? @level0name = N'dbo'?? @level1type = N'PROCEDURE'??
@level1name = N'test'
GO
EXEC sys.sp_addextendedproperty @name = N'????????'??
@value = N'CREATE PROC Test WITH ENCRYPTION AS SELECT suer_sname()??user_name() GO'??
@level0type = N'SCHEMA'?? @level0name = N'dbo'?? @level1type = N'PROCEDURE'??
@level1name = N'test'
GO
--5?????
DECLARE @pwd VARCHAR(100)= 'P@ssw0rd'
--???????
DECLARE @proc VARCHAR(100)= 'test'
--?娲�??????
DECLARE @exName NVARCHAR(100)= '????????'
--??????????
--???????????
SELECT value
FROM sys.all_objects AS sp
INNER JOIN sys.extended_properties AS P ON P.major_id = sp.object_id
AND P.minor_id = 0
AND P.class = 1
WHERE ( P.name = @exName )
AND ( ( sp.type = N'p'
OR sp.type = N'rf'
OR sp.type = 'pc'
)
AND ( sp.name = @proc
AND SCHEMA_NAME(sp.schema_id) = N'dbo'
)
)
??????
???路???
??????????????????
2023/3/23 14:23:39???写?貌??????????
2023/3/22 16:17:39????????????????????些??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???路???????路
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11