各位大神帮帮忙啊!
DECLARE @PSW VARBINARY(500) = '1'
CREATE SYMMETRIC KEY SEPARATEKEY
AUTHORIZATION sa
WITH ALGORITHM = DES
ENCRYPTION BY PASSWORD = @PSW
为什么像上面上面这种行不通,下面这种却可以呢?
CREATE SYMMETRIC KEY SEPARATEKEY
AUTHORIZATION sa
WITH ALGORITHM = DES
ENCRYPTION BY PASSWORD = '1'
我需要把一行语句给@PSW,所以要用@PSW替换,为什么不行啊……哭
------解决方案--------------------
DECLARE @PSW VARchar(500) = '1'
exec('
CREATE SYMMETRIC KEY SEPARATEKEY
AUTHORIZATION sa
WITH ALGORITHM = DES
ENCRYPTION BY PASSWORD = '''+@psw+'''')