What is Merge command?
Merge provides an efficient way to perform multiple DML operations. Using the MERGE statement we can include the logic of such data modifications in one statement that even checks when the data is matched, then just update it, and when unmatched, then insert it.
Step by step explanation of merge statement:
Step 1: Create a target table.
- create table Book
- (
- BID int identity(1,1)primary key,
- Title varchar(50),
- Quantity int,
- Price int
- )
Step 2: Create a source table.
- create table BookOrder
- (
- OID int identity(1,1)primary key,
- Title varchar(50),
- Quantity int,
- Price int
- )
- insert Book values('ASP.Net 4.0',5,890)
- insert Book values('C#.Net 4.0',8,990)
- insert Book values('ADO.Net 4.0',7,400)
- insert Book values('VB.Net 4.0',12,720)
- insert Book values('Silverlight',4,880)
- insert into BookOrder values('C#.Net 4.0',4,990)
- insert into BookOrder values('MVC4',4,1800)
- insert into BookOrder values('ADO.Net 4.0',4,400)
- insert into BookOrder values('JQuery',4,640)
- insert into BookOrder values('WCF',3,740)

Bhuvan PandeyPosted Jul 21, 2016, 8:15 AM
Thanx every one to follow my article.
SubashPosted Jul 21, 2016, 1:43 AM
Good Very Nice
Nigel FernandesPosted Jul 20, 2016, 9:44 PM
Useful
Raja TPosted Jul 20, 2016, 8:02 PM
Nice....
Mahesh ChandPosted Jul 20, 2016, 5:15 PM
Is this just SQL Server 2008 or any SQL? Or all SQL Server versions? Please clarify in the article. Most of the SQL commands usually applies to most of the common databases.
RakeshPosted Jul 20, 2016, 12:35 PM
Good share
Lalit RaghavPosted Jul 20, 2016, 6:27 AM
Nice article
kalu singh raoPosted Jul 20, 2016, 1:33 AM
Good explanations