Skip to content

Instantly share code, notes, and snippets.

@tncbbthositg
Created June 11, 2009 13:19
Show Gist options
  • Save tncbbthositg/127894 to your computer and use it in GitHub Desktop.
Save tncbbthositg/127894 to your computer and use it in GitHub Desktop.
CREATE TRIGGER Benefits.AddressHashcode
ON Benefits.Addresses
INSTEAD OF INSERT
AS
BEGIN
SET NOCOUNT ON;
INSERT INTO addresses
SELECT City, State, Zip, Street1, Street2, County,
ISNULL(
Hashcode,
HASHBYTES('SHA1', '|' + ISNULL(City, '<NULL>') + '|' +
'|' + ISNULL(State, '<NULL>') + '|' +
'|' + ISNULL(Zip, '<NULL>') + '|' +
'|' + ISNULL(Street1, '<NULL>') + '|' +
'|' + ISNULL(Street2, '<NULL>') + '|' +
'|' + ISNULL(County, '<NULL>') + '|')
)
FROM inserted;
END
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment