Skip to content

Instantly share code, notes, and snippets.

@c0ldlimit
Created January 11, 2013 20:29
Show Gist options
  • Select an option

  • Save c0ldlimit/4513717 to your computer and use it in GitHub Desktop.

Select an option

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
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