Click here to Skip to main content
15,890,579 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have one table a with column(id,name,address,city,pincode).
while inserting data into table I need to check for duplicate record.
For example if all record name,address,city and pincode is same then dont insert
else insert data in table. Table have very huge data and I need fast performance.
Please suggest best way to do this.

Thanks
Posted
Comments
CRDave1988 13-Feb-12 3:08am    
which language u r using? c#? vb?

if you are using sql server , then you can create a stored procedure like this:


IF EXISTS (SELECT Name From table1 WHERE Name =@Name and address=@address and city=@city and pincode=@pincode)

BEGIN

SET @ReturnVal ='Already Exists!'

--Return @ReturnVal

END

ELSE

BEGIN

--here execute insert query
End
end try
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900