Solved

Prevent duplicate entries

Posted on 2006-06-17
2
210 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

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…
Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

806 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