Click here to Skip to main content
15,883,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a stored procedure as follow:

SQL
insert into callbook
(
callsrno,calldate,customerid,product,modelid,srnumber
,purdate,warranty,dealerid,complaint,enqtype,callfrom
,prefdate,preftime,callstatus,ipaddr1,userid
)
 values 
(
convert(nvarchar(11),@callsrno),@calldate ,@customerid ,@product ,@modelid  ,@srnumber ,
@purdate,@warranty ,@dealerid  ,@complaint,@enqtype ,@callfrom ,
@prefdate,@preftime ,@callstatus ,@ipaddr1 ,@userid 
)


But some time more than one user accessed this sp.
and ambiguous record saved in my database.

So I want to restrict simultaneous access of SP.

Thnx...
Posted
Updated 7-Aug-12 23:24pm
v2

What do you mean by ambiguous record ?
I think you just need to implement referential contraints: for instance unique index constraints to protect your data from getting corrupted.
Because you are doing an insert the record itself that is being inserted cannot get corrupted, the only possibility I see is that it might be inserted twice if you do not have the proper referential constraints.
 
Share this answer
 
If you use MS SQL Server 2005 or higher you can use table hints such as locks (exclusive - TABLOCKX, or simple TABLOCK) to prevent simultaneous insert's in it.
http://msdn.microsoft.com/en-us/library/ms187373.aspx[^]
 
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