Click here to Skip to main content
15,885,546 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I have one table. in which i want to insert maximum three row against each key. so please tell me how to prevent it. as there are very fast (mili second) entry is being done.
Posted
Comments
syed shanu 24-Sep-14 3:48am    
Can you explain more with your example data.
[no name] 24-Sep-14 3:52am    
make clear your requirement
Gaurav Gupta A Tech Guy 24-Sep-14 8:44am    
Requirement is that i need to submit student record for their papers but condidtion is that we can't allow them to have above 3 paper for a login id. so if two candidate open the page same time with same page with same credential. so both should not be allowed.

1 solution

use strop procedure to insert your data, examples
http://www.sqlinfo.net/sqlserver/sql_server_stored_procedure_INSERT.php[^]
http://www.mssqltips.com/sqlservertutorial/2519/insert-stored-procedure-in-sql-server/[^]

In side procedure make sure you check,

If data count >= 3 for this key throw exception
else let it to be inserted

and the transaction obliviously.
 
Share this answer
 
Comments
Gaurav Gupta A Tech Guy 24-Sep-14 8:46am    
it will not solve my problem. i already know this. but for very frequent transaction. it might not work..
DiponRoy 24-Sep-14 12:55pm    
hmm ... it's true that i haven't worked with the most efficient solution.

But once i worked on a project where every table had a log table for it self. If an affect like add/update/delete was been made for a row of a table, the full row was been transferred to the log table.

and some time one requirement was affecting more that 3 or 4 main tables.

and about 450 people was been affecting rows every day. But this solution worked for us. So you can try out this. How about you make a test page like this and take a load test .. !!!

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