September 8, 2016 at 11:59 pm
I have code below and trying to rewrite the code using merge statement , but i'm pretty new to use merge any help greatly appreciate
September 9, 2016 at 7:16 am
There's no advantage to rewriting such a thing as a MERGE. I wouldn't waste my time doing such a thing.
If you want to learn MERGE, start on something simple.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 9, 2016 at 7:29 am
Any particular reason? Merge is a pain to write, no more efficient than separate statements in most cases, and has been found to have assorted bugs in it over the years.
Personally I rather avoid merge.
Gail Shaw
Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability
September 9, 2016 at 7:32 am
GilaMonster (9/9/2016)
...Personally I rather avoid merge.
Really? I now feel better about avoiding merge too. 🙂
For best practices on asking questions, please read the following article: Forum Etiquette: How to post data/code on a forum to get the best help[/url]
September 9, 2016 at 7:34 am
I feel like merge will reduce the code length and improve the performace..if that is the case i will avoid merge..or is there any we can rewrite above code for better performance..thanks
September 9, 2016 at 8:04 am
Alvin Ramard (9/9/2016)
GilaMonster (9/9/2016)
...Personally I rather avoid merge.
Really? I now feel better about avoiding merge too. 🙂
Makes three of us.
--Jeff Moden
Change is inevitable... Change for the better is not.
September 9, 2016 at 9:16 am
koti.raavi (9/9/2016)
I feel like merge will reduce the code length and improve the performace..if that is the case i will avoid merge..or is there any we can rewrite above code for better performance..thanks
It looks like you've got 4 statements there, creating a temp table, two inserts then a delete. If you run them 1 by 1 instead of as a batch is there any particular one that runs slow?
September 9, 2016 at 9:17 am
A MERGE won't work here. MERGE requires all of the actions be performed on the same table. Here you are inserting into one table (tbl_OOA_Source_Exception), but deleting from another (tbl_OOA_Source_PreScrub).
Drew
J. Drew Allen
Business Intelligence Analyst
Philadelphia, PA
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply