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 2000 Forums
 Transact-SQL (2000)
 How to implement RowLocking

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-02-08 : 10:26:12
Abdul writes "Would you please help me to solve my problem
User1 sends a query
update table1 set col2=<some value> where col1=<some value>
this query will update row 1,3,10 in the table
In the mean time User2 sends the same query which will
update row 2,4 & 5.
In SQL server user2 have to wait untill user1 ends his transaction
either by issuing commit or rollback.
Although user1 is updating row 1,3, 10 and user2 is updating
row 2,4 & 5
Is there any solution that user2 should not wait for user1's
transaction to end ?
is there any solution like rowlocking concept ?

Waiting for your reply

Thanks
Abdul Hameed

robvolk
Most Valuable Yak

15732 Posts

Posted - 2002-02-08 : 10:30:43
If you add the ROWLOCK hint to your UPDATE statements:

UPDATE table1 WITH (ROWLOCK) SET col2='new value' WHERE col1='some value'

Only the rows affected by the UPDATE will be locked. If 2 or more users are trying to UPDATE the same rows, some lock contention may occur, but it will be minor and shouldn't overly delay the UPDATE statements.

Check Books Online for "ROWLOCK" and read about the other available locking hints.

Go to Top of Page
   

- Advertisement -