Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
shaik.zakeer
Posting Yak Master
117 Posts |
Posted - 2008-06-26 : 05:46:32
|
| Hello friends...i have done some bulk insert from .txt file to database.in that i have four rows.Initially when i execute the bulk insert it inserted four into the table.when i runs bulk insert one more time it is inserting same four rows.but i dont want to allow duplicates.how can i do?please help me. is there option in bulk insert to avoid duplicatesThanks |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-26 : 06:17:42
|
| Either set a unique constraint on column of table which distinguishes unique records so that it will cause a viloation error on trying to insert duplicates.Or you can bulkinsert the data onto a temporary table and then compare this with your table and insert only missing records. |
 |
|
|
shaik.zakeer
Posting Yak Master
117 Posts |
Posted - 2008-06-26 : 06:58:40
|
| Thanks for your info.actually i have created a primary key on id column.first i inserted three rows into the table and then for the second time i have inserted four rows (along with the three old rows+one new row).But i m unable to get.Please help me out from this.Thanks |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-06-26 : 07:04:54
|
quote: Originally posted by shaik.zakeer Thanks for your info.actually i have created a primary key on id column.first i inserted three rows into the table and then for the second time i have inserted four rows (along with the three old rows+one new row).But i m unable to get.Please help me out from this.Thanks
if you want bulkinsert to happen even when you provide duplicates. ist better to use the second approach i.e inserrting into temporary table and then inserting into final table after comparison. |
 |
|
|
shaik.zakeer
Posting Yak Master
117 Posts |
Posted - 2008-06-26 : 08:58:28
|
| thanksThanks |
 |
|
|
|
|
|