|
Posted by Erland Sommarskog on 06/28/05 01:26
pk (philip.kluss@gmail.com) writes:
> ughh, bulk insert is going to be the end of me. i just need to insert
> two seperate .txt files into two separate tables, but i can't do it. i
> did finally get one to go through by not demanding that the index
> AK2IV10401 is unique. i don't know what problems that will cause for
> me in the future, but i would at least like to get to the future to see
> SOMETHING happen. As for the second table, there is a Primary Key that
> is blocking all my progress and I don't know how to get around this.
> Here is the error I get.
>
> Violation of PRIMARY KEY constraint 'PKIV10402'. Cannot insert
> duplicate key in object 'IV10402'.
> The statement has been terminated.
>
> I REALLY don't think I'm violating anything, so why is it kicking and
> screaming at me?
Because you are violating something.
Get data into a keyless staging table, and to a SELECT WHERE EXISTS
to find clashes with existing data, and "SELECT keycol, COUNT(*) FROM
tbl GROUP BY keyol HAVING COUNT(*) > 1" to find the dups in the file.
--
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se
Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinfo/productdoc/2000/books.asp
[Back to original message]
|