July 28, 2007 at 8:32 pm
Have application writing data in SQL 2005 database from a datasource
need to maintain only unique records in the database table.
No. of times the original datasource gives duplicate records which get inserted in the database, can not help to eliminate the same at the original datasource.
i have three columns.. an autoincrement ID is made a column and is primary key in SQL database
let me know what properties of the table, columns can be set that the SQl would not allow the duplicate records
July 30, 2007 at 12:30 am
If the Datasource is Text file , then first transfer the text file to some temp table and then compare the temp souce table and Table where u want to insert the data.
After that derive the final table for inserting and insert it to database.
you need to combine the columns to maintain the uniquness of row and then same column can be used for checking while transferring the data from datasource.
July 30, 2007 at 4:05 am
The autoincrement will be unique (unless you are turning off the identity in your import).
Creating a unique index on one (or all) of your other columns will prevent duplicates in your data. However if you then import straight into the table and include duplicates then the import will fail.
The advice in the previous post is good - import to a temp table, clean the data then proceed.
As an alternative, you could try an 'instead of insert' trigger on your table. Import as needed, and put any duplicates to a holding table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply