PDA

Click to See Complete Forum and Search --> : Duplicate Records


smartbid
Jan 8th, 2000, 11:10 AM
How do I check for duplicate records in
a field that does not allow duplicates.

jim

Clunietp
Jan 9th, 2000, 12:00 AM
If the field already does not allow duplicates, it will perform the validation for you. All you have to do is handle the error that will be generated

JHausmann
Jan 11th, 2000, 04:58 AM
Tom, there are instances in SQL server when you can have a field that does not allow duplicates that has them. BCP, for example, can do this on SQL Server.

smartbid,

select key, count(key) from table group by key

will give you a list of all your keys (replace the word 'key' with your fieldname) and the number of times they occur. If you get a count greater than 1, you have duplicates.

Clunietp
Jan 11th, 2000, 12:10 PM
Would that be the exception, not the rule?

Is it not wise to allow the DBMS to perform the validation with normal transactions?

JHausmann
Jan 11th, 2000, 10:03 PM
Definitely.

Sometimes you don't get a choice, BCP is a good example.