views:

70

answers:

1

Hello everyone,

I am learning and using SQL Server 2008 new Merge statement, merge statement will compare/operate source table and destination table row by row ("operate" I mean operations performed for when matched or not-matched conditions). My question is whether the whole merge process will be one transaction or each row comparison/operation will be one transaction?

Appreciate if any document to prove it.

thanks in advance, George

+1  A: 

The merge statement is a set based operation and as such will operate on the entire set of matching rows.

It is very much like an UPDATE or DELETE. If you want to (and sounds like you do), you can wrap it with a BEGIN TRAN and COMMIT for data integrity purposes.

Raj More
So, you mean the whole merge will be in one transaction? If yes, any document (e.g. MSDN) to prove? I did not find such document so far.
George2
@George2 - answer edited
Raj More
Thanks! After reading your reply, I am still confused. Could you clarify whether the whole merge statement acts as a transaction or each row operation within merge statement acts as a transaction?
George2
The MERGE statement is atomic, it will either all fail or all succeed, there's no scenario where you would have half of it processed.
SqlACID
Hello SqlACID, do you have any document to prove?
George2
@George2, I could not find the documentation. Perhaps you can post at the MSDN forums http://goo.gl/hgl3
Raj More
Thanks, man! :-)
George2