开发者

Compute hash-value of entered value when insert or update using sql server 2008 by triggers

I have a table with two column开发者_StackOverflow社区s {FlatContent, HashedContent}. Now I want to automatically compute the hash value of FlatContent when new row was inserted or an existing row was updated. To date, I've never used from trigger, so I can't do this by trigger or another approach which is exist to solve this issue.

Thanks if anybody can help me ;)


Instead of using a trigger, make HashedContent a persisted computed column in your table definition.

ALTER TABLE YourTable
    ADD HashedContent AS HashBytes('SHA1', FlatContent) PERSISTED
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜