Skip to content

Instantly share code, notes, and snippets.

@marifrahman
Created June 28, 2013 07:16
Show Gist options
  • Save marifrahman/5883017 to your computer and use it in GitHub Desktop.
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
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