Created
June 28, 2013 07:16
-
-
Save marifrahman/5883017 to your computer and use it in GitHub Desktop.
Sql server specific SQL to update a record if exists or insert as new
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
IF EXISTS (SELECT NULL FROM myTable WHERE myId = 'something') | |
UPDATE myTable SET some_other_column = 'some_other_thing' | |
ELSE | |
INSERT INTO myTable Values('something', 'some_other_thing',some_flag_may_be) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment