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)
 row Locking Problem

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-11-12 : 08:50:48
Anand Sharma writes "Hi


I am facing a problem while locking some rows of a table SQL
database.

I am having a table named as "Users".
I have written code in the following way.

Begin transaction
Select * from users
with (HOLDLOCK , ROWLOCK)
where userid = 10


Problem is that nobody is able to update
other rows also. I have locked only a single
row with userid = 10 but it seems that the
whole table is locked.

Could u please help me out.

SQL Server version = 7.0
Window NT 4
service pack = 6


Thanx
Anand"

smccreadie
Aged Yak Warrior

505 Posts

Posted - 2002-11-12 : 09:22:03
Why are you row-locking? Seems like a better way would be to design your project so that explicit locking is not needed.

Go to Top of Page

rihardh
Constraint Violating Yak Guru

307 Posts

Posted - 2002-11-12 : 10:13:54
Row locking is not, I repeat NOT intended for MSSQL. Drop that Access way of programing...

Go to Top of Page

burbakei
Yak Posting Veteran

80 Posts

Posted - 2002-11-13 : 13:42:24
In SQL SERVER row level locking is enabled by default. but sometime sql server
promotes row locking to page locking and even table locking. if your table is has a few rows that occupies only one or so pages it is likely that sql server
propotes your row lock to table lock in order to (yes) consume less recources.


Go to Top of Page
   

- Advertisement -