Question

I have a table with two columns {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 ;)

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top