Results 1 to 2 of 2
  1. #1
    Join Date
    Sep 2003
    Posts
    2

    Question Unanswered: How do I lock a record in ms-Sql 2000 in a Stored Procedure

    Let say 3 person update the same record at the same time the count field must be increment 3.

    I want to search for the record on id.
    Lock the record so other users can't READ the record
    Read the count field of the record
    ad +1 to the count
    update the record with the new count
    unlock the record so other user can increment the count on the same record.

    Is there a beter way to do this?

    All the user will run the same Storedprocedure

  2. #2
    Join Date
    Jul 2002
    Location
    Village, MD
    Posts
    621

    Re: How do I lock a record in ms-Sql 2000 in a Stored Procedure

    Originally posted by ddp2307
    Let say 3 person update the same record at the same time the count field must be increment 3.

    I want to search for the record on id.
    Lock the record so other users can't READ the record
    Read the count field of the record
    ad +1 to the count
    update the record with the new count
    unlock the record so other user can increment the count on the same record.

    Is there a beter way to do this?

    All the user will run the same Storedprocedure
    Also, you could use optimistic concurrency - for details see BOL.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •