Hello, SQL 2008R2
What is the best way to check for a duplicate value when inserting into an encrypted column?
I know I can do this:
however, I would like to put safe guards on the table to keep someone from inserting a douplicat by on criteria.
Something like a instead of trigger.
Thanks,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
What is the best way to check for a duplicate value when inserting into an encrypted column?
I know I can do this:
Code:
INSERT INTO MyTable (EncryptedNumber)
SELECT DISTINCT EncryptByKey(Key_GUID('My_Key_01'), '123123456123456789') AS EncryptedNumber
WHERE NOT EXISTS (SELECT * FROM MyTable
WHERE CONVERT(varchar, DecryptByKey(EncryptedNumber)) = '123123456123456789')
Something like a instead of trigger.
Thanks,
djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!