Skip to content

Instantly share code, notes, and snippets.

@FilipDeVos
Created May 16, 2011 14:08
Show Gist options
  • Save FilipDeVos/974501 to your computer and use it in GitHub Desktop.
Save FilipDeVos/974501 to your computer and use it in GitHub Desktop.
Thread Safe Insert/Update
CREATE PROCEDURE updatevalues(@id int,
@name varchar(20),
@amount numeric)
AS
IF EXISTS(SELECT * FROM updatetest WHERE id = @id)
BEGIN
UPDATE updatetest
SET name = @name,
amount= @amount
WHERE id = @id
END
ELSE
BEGIN
INSERT INTO updatetest VALUES (@id, @name, @amount)
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment