Printed 2017/07/21 11:11AM

How Should It Work?

By Steve Jones, 2008/03/28

I was following a debate on the new Merge syntax in SQL Server 2008 with interest. It was somewhat of a debate about hot things should work, what happens with NULLs, etc. Now I don't want to recreate it here, but one thing was interesting to me. What would you expect from this?


Merge (select top 1 * from xxx where yyy)

 when matched ....

 when not matched ...



How many rows should be inserted? Would the top 1 that matched each section be inserted? I'd think only 1 row would be processed. To me the MERGE statement should only have 1 row input to it and whichever section it matched would process it.

 Is this not intuitive to anyone else?

Copyright © 2002-2017 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.