Last active
May 18, 2019 18:04
-
-
Save stevetranby/648075 to your computer and use it in GitHub Desktop.
Quick if exists update else insert MSSQL
This file contains hidden or 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 Users WHERE Email=@Email) | |
UPDATE Users SET Name=@Name WHERE Email=@Email | |
ELSE | |
INSERT INTO Users(Email, Name) VALUES (@Email, @Name) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
In this example setting a user of your system's Name based on their unique id being Email :D