Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase «««123

The Power of Merge Expand / Collapse
Author
Message
Posted Friday, September 14, 2007 4:14 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 24, 2013 4:42 AM
Points: 460, Visits: 2,523

The examples were created with SQL Server 2008. SQL Server 2005 does not support MERGE. It is available only with SQL Server 2008

You can download SQL server 2008 (KATMAI) at https://connect.microsoft.com/SQLServer/content/content.aspx?ContentID=5395



.
Post #399224
Posted Saturday, September 15, 2007 10:36 PM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, March 31, 2010 6:02 PM
Points: 174, Visits: 2,075

Jacob, Wayne, Charles and other interested parties,

There is the sql standard and then there is the 'relational' approach. I urge you to compare S2008 MATCH with the ideas presented here:

http://beyondsql.blogspot.com/2007/06/dataphor-intelligent-views.html

We should be talking about intelligient operations on 'views'. And views are something sql has...well dumbed down

MATCH, conceptually, has much in common with the S2008 idea of a table parameter. I'm trying to show these concepts in a mature form now, as opposed to the MS siblings of pre-adolescence

www.beyondsql.blogspot.com

I hope to be presenting at the Phoenix SQL Server User Group soon. I will try to make things lively and informative

Post #399543
Posted Wednesday, March 19, 2008 5:10 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, July 16, 2014 11:50 AM
Points: 6, Visits: 353
Has anyone compared the performance of a MERGE statement with the "old" standard of UPDATE and INSERT? Specifically with regards to data warehouse loading.

Thanks,

jake



Post #472009
Posted Wednesday, March 19, 2008 7:34 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, July 2, 2014 1:41 AM
Points: 164, Visits: 364
Yes, it's faster. It doesn't need to loop through the data multiple times to find out which rows exist and therefore need updating, and which ones don't and therefore need inserting.


Rob Farley
LobsterPot Solutions & Adelaide SQL Server User Group
Company: http://www.lobsterpot.com.au
Blog: http://sqlblog.com/blogs/rob_farley
Post #472032
Posted Tuesday, January 13, 2009 10:00 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Wednesday, January 14, 2009 3:29 PM
Points: 1, Visits: 5
How can I accomplish the same result albeit slower in SQL Server 2005 - not using MERGE?
Post #635598
Posted Tuesday, January 13, 2009 11:10 PM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, December 24, 2013 4:42 AM
Points: 460, Visits: 2,523
In SQL Server 2005, you would need three separate DELETE, UPDATE and INSERT statements. You can find an example (look at the last example) here: http://www.sqlservercentral.com/columnists/jSebastian/2912.asp

.
Post #636021
Posted Thursday, September 15, 2011 2:42 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Thursday, July 17, 2014 6:34 AM
Points: 10, Visits: 112
Hi Sebastian,

On going thru your code, i could notice that you are delete the records by ...WHEN SOURCE NOT MATCHED THEN DELETE;

i suppose that it would delete all other records which doesn't meet the on clause join condition of the merge, like orderdetails of other orders ..........

Pls. clarify me...
Post #1175469
Posted Wednesday, June 27, 2012 5:25 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, June 10, 2014 11:48 AM
Points: 11, Visits: 106
I was working with SQL 2008 R2 and found that to use delete when there is no match, the syntax got changed.
Instead of

"WHEN SOURCE NOT MATCHED THEN
DELETE;"


It is now

"WHEN NOT MATCHED BY SOURCE
THEN DELETE;"



Hope you guys have noticed. But Just an FYI
Post #1322224
« Prev Topic | Next Topic »

Add to briefcase «««123

Permissions Expand / Collapse