Click here to Skip to main content
16,023,224 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I want to write a stored proc to insert some data in a table...but before that I want to check whether that record is already present in table or not. If yes then it should display some message like "duplicate data"

I am inserting the data from front end.

And also how to catch that msg in front end.

Please help me.

Thanks in advance.
Posted
Updated 12-Jul-10 19:14pm
v4
Comments
TheyCallMeMrJames 13-Jul-10 1:14am    
I edited to REMOVE ALL THE CAPS YOU WERE USING and change your generic title. Please don't yell in your questions and use more meaningful titles.

1 solution

Well, based on the issue:
1. One of the good ways would be to put unique constraint on the table itself! It will check before inserting.
2. If you want to do it in UI, then get all data and check in a loop. But that would be a lengthy procedure.

Option1 is good for you.

UPDATE:
Look here: MSDN - UNIQUE Constraints[^
 
Share this answer
 
v2
Comments
shekhar009 13-Jul-10 1:49am    
Thanks.But can u provide me some code snippet as an example.
Sandeep Mewara 13-Jul-10 2:10am    
Updated my answer with a link.

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