需要帮助来纠正sql查询中的语法。
OPEN SYMMETRIC KEY symmetrickey_ccprocessing
DECRYPTION BY CERTIFICATE certificate_ccprocessing;
SET NOCOUNT ON;
select CONVERT(VARCHAR, DECRYPTBYKEY(c.CR_CARD_NBR)) AS CR_CARD_NBR
from dbo.credit C
CLOSE SYMMETRIC KEY symmetrickey_ccprocessing;
我需要列CR_CARD_NBR的前两个字符。 如何使用字符串并使用解密密钥进行转换。
提前致谢。
答案 0 :(得分:0)
用左(xxx,2)包围它,就像这样;
OPEN SYMMETRIC KEY symmetrickey_ccprocessing
DECRYPTION BY CERTIFICATE certificate_ccprocessing;
SET NOCOUNT ON;
select LEFT(CONVERT(VARCHAR, DECRYPTBYKEY(c.CR_CARD_NBR)),2) AS CR_CARD_NBR
from dbo.credit C
CLOSE SYMMETRIC KEY symmetrickey_ccprocessing;