Results 1 to 4 of 4

Thread: BCP - Some Doubts

  1. #1
    Ramesh Guest

    BCP - Some Doubts

    Hi,

    I am currently using SQL Server version 6.5 and am trying to execute the BCP command
    from the command prompt to update my database. Right now, if the tables doesn't have
    any primary key constraints, the BCP works fine and inserts all the rows to the database.
    Suppose the table has some primary keys and the datafile to the BCP has some duplicate
    records in it. It says, the following

    Starting copy...
    Msg 2627, Level 14, State 1:
    Server 'DHRUVA', Line 1:
    Violation of PRIMARY KEY constraint 'PK_docket_booking4_1__10':
    Attempt to insert duplicate key in object 'docket_booking4'.

    It does not insert any rows to the database. Is there anyway I can overcome this error and
    proceed on with the BCP to copy data. THe datafile which I give will have duplicate records.

    regards
    Ramesh Seetharaman.

  2. #2
    Craig Guest

    BCP - Some Doubts (reply)

    Take the indexes off or modify the index in question to not be unique or set ALLOW_DUP_ROW. See books online under CREATE INDEX............


    ------------
    Ramesh at 7/29/99 2:23:25 AM

    Hi,

    I am currently using SQL Server version 6.5 and am trying to execute the BCP command
    from the command prompt to update my database. Right now, if the tables doesn't have
    any primary key constraints, the BCP works fine and inserts all the rows to the database.
    Suppose the table has some primary keys and the datafile to the BCP has some duplicate
    records in it. It says, the following

    Starting copy...
    Msg 2627, Level 14, State 1:
    Server 'DHRUVA', Line 1:
    Violation of PRIMARY KEY constraint 'PK_docket_booking4_1__10':
    Attempt to insert duplicate key in object 'docket_booking4'.

    It does not insert any rows to the database. Is there anyway I can overcome this error and
    proceed on with the BCP to copy data. THe datafile which I give will have duplicate records.

    regards
    Ramesh Seetharaman.

  3. #3
    Guest

    BCP - Some Doubts (reply)

    Is there anyway I keep the Uniqueness intact and still perform the BCP. What I mean, I do not
    want the table to contain duplicate rows to maintain data integrity,but the text file which is the
    data file may contain duplicate rows in it and is bound to have 1000+ records in it.

    ramesh


    ------------
    Craig at 7/29/99 5:04:42 AM

    Take the indexes off or modify the index in question to not be unique or set ALLOW_DUP_ROW. See books online under CREATE INDEX............


    ------------
    Ramesh at 7/29/99 2:23:25 AM

    Hi,

    I am currently using SQL Server version 6.5 and am trying to execute the BCP command
    from the command prompt to update my database. Right now, if the tables doesn't have
    any primary key constraints, the BCP works fine and inserts all the rows to the database.
    Suppose the table has some primary keys and the datafile to the BCP has some duplicate
    records in it. It says, the following

    Starting copy...
    Msg 2627, Level 14, State 1:
    Server 'DHRUVA', Line 1:
    Violation of PRIMARY KEY constraint 'PK_docket_booking4_1__10':
    Attempt to insert duplicate key in object 'docket_booking4'.

    It does not insert any rows to the database. Is there anyway I can overcome this error and
    proceed on with the BCP to copy data. THe datafile which I give will have duplicate records.

    regards
    Ramesh Seetharaman.

  4. #4
    B Guest

    BCP - Some Doubts (reply)

    NO, You are asking SQL to violate a rule that you are telling it to enforce. Craig has given you the only possible answer.
    The only other possible way around this is to BCP into another table. A table specifically designed without the index. Then you could remove the dups from this table, clean up the primary key problems and then insert the cleaned records into the table that has the proper keys.

    BCP is doing what it is supposed to do according to how you set up the table.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •