Created
January 11, 2013 20:29
-
-
Save c0ldlimit/4513717 to your computer and use it in GitHub Desktop.
#SQL IF EXIST UPDATE ELSE INSERT for SQL Server 2005 because it doesn't have the merge operation
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
| UPDATE dbo.customer_comments | |
| SET customer_comment= @comment + 'something here' | |
| WHERE customer_id = @customerId | |
| IF @@ROWCOUNT = 0 | |
| INSERT INTO dbo.customer_comments (customer_id, customer_comment) | |
| VALUES (@customerId, @comment) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment