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)
 facing problem with locking hint rowlock

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-09-19 : 09:25:27
Praveen writes "I want a row level lock.If I use this select statement then only I get proper result.

SELECT * FROM table WITH (REPEATABLEREAD, ROWLOCK ) WHERE id ='MyId';
id is unique key.
I am testing through two sql query analyzer tool for sql server 2000.From other query analyzer tool I can easily modify other rows which I have not locked.

All other Lock Option-HOLDLOCK,UPDLOCK,XLOCK, SERIALIZABLE are not giving desired row lock even used with rowlock option.Either they are locking table or page.I can not modify other rows also.I do not know how lock escalation property is affecting the result.Even at the url ( "http://www.sqlteam.com/item.asp?ItemID=250" ) ,U have given this statement to use for row level locking
SELECT *
FROM authors
WITH (HOLDLOCK, ROWLOCK)
WHERE au_id = '274-80-9391'

I want to know

1.Why this not working in my case.
2.Like oracle if I fire one "select..for update" in one prompt & if i try same query through other sql prompt I get resource locked exception.Can I get same thing in sql server where only one query will obtain lock also & give resource locked exception if that row is already locked or I need to fire two query one above select query & one update query for getting already locked row exception."
   

- Advertisement -