|
Posted by rcamarda on 04/28/06 21:28
Hello,
While working through my encryption questions from preivous posts, I am
finding that I may have to resort to use triggers to do the encryption
(not that this is the only way, but might be the best way for my
circumstances).
I would like to create a trigger that will encrypt the field before the
write is committed.
I've found serveral posts about triggers, but nothing that fits what I
wish to do.
Upon an insert or update I want to modify the ssn field with this:
cast(EncryptByAsymKey(AsymKey_ID('Student_aKey'), cast(SSN as
nvarchar(11))) as nvarchar(40))
so, ssn '123456789' in SSN would become <something encrypted> in SSN
This is the trigger I have so far, but it is generating an error:
CREATE TRIGGER F_Student_SSN.eSSN
ON F_STUDENT_SSN
INSERT, UPDATE
AS SELECT cast(EncryptByAsymKey(AsymKey_ID('Student_aKey'), cast(SSN as
nvarchar(11))) as nvarchar(40))
TIA
Rob
Navigation:
[Reply to this message]
|