how to avoid Duplicate when you insert record

Am trying to insert a record pulled out from Active Directory but i can see so many duplicates,how can i avoid when i insert those records.

for eg repeat 5 times,i just don't want to insert a duplicate record based on mail id.

any one pleas enlighten me.

Thanks in Advance
Who is Participating?
ramkihardyConnect With a Mentor Commented:
simple you can set the maildid column unique in the table which you want to enter.......
when you try to insert a duplicate email throws an error...catch that error it consist of errorid for duplicate record can check if duplicate record inserted in
if(errid=="error id for duplicate record insertion")
{"Record alreadyb exist");
2.Otherwise you have to select the distinct record so that it wont contain any duplication...
exceterConnect With a Mentor Commented:
Also you can create a temporary table and insert there initially with INSERT INTO .... SELECT DISTINCT EmailID...
Sha1395Author Commented:
Thanks Ramki and Exceter.

As you people mentioned i make Email Id is a primary key and use TRY  Catch in my code.its done.

Thanks again for all your help
Please mark it as accepted solution...
Thanks & regards
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.