Solved

Prevent duplicate entries

Posted on 2006-06-17
2
209 Views
Last Modified: 2010-07-27
Hi experts,

I have a sp that inserts (registers) user, how can I stop getting multiple entries of the same user, for example, an operator enters the following details:

First Name: Wayne
MiddleName: A
LastName : Atherton
etc......


the sp returns an out put value for the new user id, so how do I prevent another user being entered with exactly the same details, currently after i insert a new users a auto number is created to represent the user.

cheers

Wayne
0
Comment
Question by:watherton
2 Comments
 
LVL 52

Accepted Solution

by:
Carl Tawn earned 100 total points
ID: 16926905
Just get your SP to check for an existing record first and return its ID if found, otherwise it adds it as a new record. Something like:

     IF NOT EXISTS(SELECT YourFields FROM YourTable WHERE YourCriteria)
     BEGIN
         /* Insert a new record */
     END
     ELSE
     BEGIN
        /* Retrieve the existing record */
     END
0
 

Author Comment

by:watherton
ID: 16927092
thanks carl, job for the db team them - great stuff :-)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction                                                 Was the var keyword really only brought out to shorten your syntax? Or have the VB language guys got their way in C#? What type of variable is it? All will be revealed.   Also called…
In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now