failing on only a portion of MERGE / BULK rows

  • I have a statement like:

    MERGE INTO [tablename] USING (SELECT [columns] FROM OPENROWSET (BULK [datafile] ..., FORMATFILE=, FIRSTROW =2 )

    We've encountered the possibility that a small number of the rows to be inserted may fail foreign key constraints. Is there any way to perhaps set a threshold of the number of acceptable errors, or in any case, to figure out (e.g. print an error) when any of them fail, rather than failing the entire bulk merge on account of a couple of bad rows?

  • Maybe an instead of trigger on the target table?

    Could also maybe use an ignore_constraints hint then clear the table up afterwards but that would probably mean keeping it locked.


    Cursors never.
    DTS - only when needed and never to control.

  • Why would you have to keep the table locked if you used ignore_constraints?

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply