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
 SQL Server Development (2000)
 Locking in SQL Server

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-07-14 : 07:28:29
Vipin writes "Hi,

I am new to SQL Server and is experienced with Oracle. In oracle for maintaining concurrency, we perform SELECT FOR UPDATE. I wanted to know the corrsponding option in SQL Server.

The situation is like, I am having a table TRANSACTIONS, which has a trans_id, some more columns and updt_stamp_dt.

Now whenever somebody wants to modify a record I will select the upd_stamp_dt for the record and store it in a variable.

I want to lock the record, do the modification and then while doing the actual update i will again check whether the upd_stamp_dt of the record I am going to update is same as the value that I have in the variable. If not I will throw a error that "data had been updated since modified it". I want also to throw an error when I try to lock the record, if the record is already locked by any transaction to try saying "try after some time".

This way I will be able to handle both concurrency and consistency.

Please advice me how to do this SQL Server 7 and 2000.

Thanks in advance"

setbasedisthetruepath
Used SQL Salesman

992 Posts

Posted - 2003-07-14 : 09:06:26
Read up on transaction isolation levels in Books Online. If you're new to SQL Server I suspect the background information there will help.

Jonathan
{0}
Go to Top of Page
   

- Advertisement -