468,247 Members | 1,317 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,247 developers. It's quick & easy.

How to prevnt duplicate PKs when using SqlBulkCopy

Hi All,

I am using the SqlBulkCopy for import data into ms sql 2005. I ran a test
when Imported the same 2 files one after another and each one had the same
PK values, but somehow it went through and got duplicate PKs. I thought that
ms sql will gen an err.

Any idea?

Thanks,

Steve
Oct 20 '08 #1
2 1108
Do it again....You must be mistaken..
Double check that you have Primary Key set to what you think it is...

George.

"SteveB" <St****@Hotmail.comwrote in message
news:O9**************@TK2MSFTNGP02.phx.gbl...
Hi All,

I am using the SqlBulkCopy for import data into ms sql 2005. I ran a test
when Imported the same 2 files one after another and each one had the same
PK values, but somehow it went through and got duplicate PKs. I thought
that ms sql will gen an err.

Any idea?

Thanks,

Steve
Oct 21 '08 #2
if you have a primary key defined on the table it will gen an error, as
dups can not be inserted. if you drop it before the load, then you must
cleanse the data before loading.

-- bruce (sqlwork.com)

SteveB wrote:
Hi All,

I am using the SqlBulkCopy for import data into ms sql 2005. I ran a test
when Imported the same 2 files one after another and each one had the same
PK values, but somehow it went through and got duplicate PKs. I thought that
ms sql will gen an err.

Any idea?

Thanks,

Steve

Oct 21 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Spam Catcher | last post: by
4 posts views Thread by Chris | last post: by
2 posts views Thread by Amar | last post: by
2 posts views Thread by SteveB | last post: by
reply views Thread by kermitthefrogpy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.