I have a stored procedure that adds a customer record and check for duplicates entries before adding the new record. The procedure check is on the name and surname fields.
My goal is to prevent the same user from entering duplicates entries.
I'm getting hung-up on syntax:
SQL
ALTERPROCEDURE[dbo].[insert_customers]@titlevarchar(4),@namevarchar(50),@surnamevarchar(50),@addressvarchar(50),@postcodevarchar(50),@cityvarchar(50)ASDECLARE@countintSELECT@count=0SELECT@count=COUNT(*)FROMcustomersWHEREdbo.customers.name=@nameANDdbo.customers.surname=@surnameIF(@count=0)BEGINSETNOCOUNTON;SELECTid,title,name,surname,address,postcode,cityFROMcustomersINSERTINTOcustomers(title,name,surname,address,postcode,city)VALUES(@title,@name,@surname,@address,@postcode,@city)PRINT'Customer record...