You are here: Trigger to encrypt field before write « MsSQL Server « IT news, forums, messages
Trigger to encrypt field before write

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация