Friday, March 23, 2012

Lock and update problem

Hello,
I use sql server 2000.
I want to create the following stored procedure:
I have a table with serveral field including the field "isqueued"
I want to select one record (select top 1) from the table and immediatly
update the iqueued field to "true" while locking the record.
This to make sure that no other thread is going the read the same record and
use it.
Any ideas on how to do this?
Thanks in advance for the helpGM
BEGIN TRAN
SELECT <> FROM Table WITH (UPDLOCK,HOLDLOCK) WHERE blbalabl;
UPDATE Table_Other SET blblb;
COMMIT
Note : There is not true datatype in SQL Server . You probably menat to
update this column to 1 OR 0 did not you?
"GM" <invalid@.invalid.com> wrote in message
news:%239$Li0kBGHA.1372@.TK2MSFTNGP14.phx.gbl...
> Hello,
> I use sql server 2000.
> I want to create the following stored procedure:
> I have a table with serveral field including the field "isqueued"
> I want to select one record (select top 1) from the table and immediatly
> update the iqueued field to "true" while locking the record.
> This to make sure that no other thread is going the read the same record
> and use it.
> Any ideas on how to do this?
> Thanks in advance for the help
>|||> Note : There is not true datatype in SQL Server . You probably menat to
> update this column to 1 OR 0 did not you?
>
Indeed, 0 or 1
I'll give this a try|||have you considered using a message queue?

No comments:

Post a Comment