Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 log the failed records for a MERGE statement

Author  Topic 

vasu4us
Posting Yak Master

102 Posts

Posted - 2009-07-28 : 13:58:48
Hi All
I have a SSIS package that does a type 1 SCD fro me and at the end i have redirected the failed records to a text file.

Is there a option to do the same with a MERGE statement

MERGE TARGETTABLE
USING SOURCETABLE
WHEN FOUND UPDATE
WHEN NOT FOUND INSERT
**THEN I WANT TO RECORD ALL THE FAILED RECORDS

I failed to figure out a way using a stored proc or any other options.

any coments and ideas appriciated.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-28 : 16:05:10
You have the LOOKUP.



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-07-28 : 17:10:09
MERGE doesn't work like that. It's atomic. So you get all or nothing.
Go to Top of Page

Andrewra
Starting Member

17 Posts

Posted - 2009-07-29 : 13:42:21
check out this articl it might help you http://www.ralphkimball.com/html/08dt/KU107_UsingSQL_MERGESlowlyChangingDimension.pdf

Andrew Alexander
LiveLogic
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-07-29 : 16:00:05
I blogged about it today
http://weblogs.sqlteam.com/peterl/archive/2009/07/29/How-to-insert-into-two-tables-in-one-statement.aspx



N 56°04'39.26"
E 12°55'05.63"
Go to Top of Page
   

- Advertisement -