How do I check for duplicate records in
a field that does not allow duplicates.
jim
Printable View
How do I check for duplicate records in
a field that does not allow duplicates.
jim
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
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.
Would that be the exception, not the rule?
Is it not wise to allow the DBMS to perform the validation with normal transactions?
Definitely.
Sometimes you don't get a choice, BCP is a good example.