Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Other SQL Server Topics (2005)
 how to lock table in store procedure

Author  Topic 

ahteshs
Starting Member

1 Post

Posted - 2008-08-19 : 00:54:56
hey ,

i do not know that is my strategy is right or not (plz tell me if its not right, give me any suggestion). i want that when i select a row from table in my database which is store in sql server 2005 by using store procedure .

e.g.

select * from mytable where proId=4 it lock the table for that proId

then whenever any other store procedure call same store procedure with same "proId" it get message that its locked or somthing .

so if the user change the quantity of that product by buying it , other has to wait till that user buy or not

i want to do tha if there is one product quantity and both access at same time ,

so if i lock when first user get that product i think i can solve this . but how can i do that in store procedure in MS SQL Server 2005

any help or suggestion will be great help to me and thanks in advance

sorry for this simple question.

Ahtesham

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2008-08-19 : 02:02:09
You could update a column called "locked" for example. In other words, and UPDATE statement to lock,
and then if you need to unlock do another UPDATE statement to unlock

Jack Vamvas
--------------------
Search IT jobs from multiple sources- http://www.ITjobfeed.com
Go to Top of Page
   

- Advertisement -