Skip to content

Instantly share code, notes, and snippets.

@stevetranby
Last active May 18, 2019 18:04
Show Gist options
  • Save stevetranby/648075 to your computer and use it in GitHub Desktop.
Save stevetranby/648075 to your computer and use it in GitHub Desktop.
Quick if exists update else insert MSSQL
IF EXISTS (SELECT NULL FROM Users WHERE Email=@Email)
UPDATE Users SET Name=@Name WHERE Email=@Email
ELSE
INSERT INTO Users(Email, Name) VALUES (@Email, @Name)
@stevetranby
Copy link
Author

In this example setting a user of your system's Name based on their unique id being Email :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment