CodePudding user response:
Use the MERGE forhttps://blog.csdn.net/sinat_28984567/article/details/79861811
CodePudding user response:
The upstairs is better,IF the EXISTS (SELECT * FROM Table1 WHERE Id=@ Id)
The BEGIN
The UPDATE Table1 SET Column1=@ newValue WHERE Id=@ Id
END
The ELSE
The BEGIN
INSERT INTO Table1 (Id, Column1) VALUES (@ Id, @ newValue)
END