sql
syntax of using both insert and update in a single query
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted Mar 7, 2012, 12:38 AM
MERGE is a new feature that provides an efficient way to perform multiple DML operations. In previous versions of SQL Server, we had to write separate statements to INSERT, UPDATE, or DELETE data based on certain conditions.
MERGE [AS TARGET] [AS SOURCE] ] ] ];
USING
ON
[WHEN MATCHED
THEN
[WHEN NOT MATCHED [BY TARGET]
THEN
[WHEN NOT MATCHED BY SOURCE
THEN
please refer,
http://weblogs.sqlteam.com/peterl/archive/2007/09/20/Example-of-MERGE-in-SQL-Server-2008.aspx
http://www.codeproject.com/Articles/37172/Merge-Statement-in-SQL-Server-2008
hope this help.