bulk copy primary key violation


  •   how   can i  bulk copy  with removing duplication.  when i use bulk copy  & insert data in table if any duplication occur it roll back  all the data.

    have any  solution for   bulk copy with duplication  check and  sucessfully inserction...............

    Tuesday, July 17, 2012 1:25 PM

All replies

  • I don't believe there is a way around this issue when using SQLBulkCopy

    In any event, these type of operations are generally time consuming so you may want to consider selecting only those rows where the primary key is not in the destination table when building your datareader.

    Tuesday, July 17, 2012 1:27 PM
  •  if  you  set primary  key in one column in table  & then use bulk copy to  insert  large amount of data in  table. if any  duplication occur  during inserction  it  rollback all the data. sir if  you have any  standard  solution  or any  .dll for bulkcopy  with duplicate check please suggest me.

    i am searching    solution   from one  month. please  sir  help me.........................


    • Edited by SATYA karsh Wednesday, July 18, 2012 1:46 PM
    Wednesday, July 18, 2012 5:56 AM
  • I would suggest you to use SSIS to load data from source into destination.
    Wednesday, July 18, 2012 6:17 AM
  • thanks  sir  for  reply.  i try   SSIS .  if i will face  any problem . i will  discuss  with u.

    really thanks  for  reply .................


    Wednesday, July 18, 2012 6:38 AM
  • sorry  sir .

                    but  with  SSIS   same problem . it rollback all  the data  if any duplication  occur  during bulk insert.

    i think  bulk copy not support duplication check.

    • Edited by SATYA karsh Wednesday, July 18, 2012 1:12 PM
    Wednesday, July 18, 2012 1:11 PM
  • With SSIS you can check which rows already exist, and skip them.
    Thursday, July 19, 2012 6:09 AM
  • how  sir.

    if  you have any sample or tutorial link please   give  me..........

    or you can send  any sample code in this email id.

    • Edited by SATYA karsh Thursday, July 19, 2012 12:45 PM
    Thursday, July 19, 2012 12:31 PM
  • Check this post where it explains how to import data with SSIS.

    SQL Server Integration Services (SSIS) – Part 1: Basics of SSIS and Creating Packages

    Thursday, July 19, 2012 2:23 PM
  • does   SSIS   can be  used for import   EXCEL bilk import  into  database
    Friday, July 20, 2012 7:01 AM
        SET A.NAME = + ',' +  B.NAME
    FROM sp A, sp1  B 
    WHERE A.roll_number = B.roll_number  ;

     above  query not update  all  the data from sp1. it only  get first  record from sp1 . how   get all the the record from sp1   which satisfy above condition..........

    Tuesday, July 24, 2012 5:07 AM