Results 1 to 7 of 7

Thread: Locking a table

  1. #1
    Join Date
    Feb 2004
    Location
    Rhode Island
    Posts
    69

    Unanswered: Locking a table

    Can any one please tell me how to lock & unlock a table a from inside a store procedure using T-SQL
    thanks

  2. #2
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    That's best left to the optimizer....

    Why?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  3. #3
    Join Date
    Feb 2004
    Location
    Rhode Island
    Posts
    69
    Brett,
    I am not sure. Some one in my devlopment team asked me that.
    I have done using DAO from VB front end. But not thru stored procedure

    thanks

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Just think of it this way...as a way to approach working with the database...

    Keep all transactions as short as possible...

    If someone is interested in locking a table, then that aint short...

    Don't leave open record sets...

    Get in, get the data, save it to an array and get out..

    sprocs are the way to go...

    My Own opinion

    MOO
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Feb 2004
    Location
    Rhode Island
    Posts
    69
    Thanks Brett,
    I guess their main concern is in that fraction of minutes if some one pulls the record for update while this procedure is being executed.

    Masanam,

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Yes,

    and that is why there should be an update_ts column...

    such that the process should check to see if the record was updated before you overlay with your update...

    You should tell the user that the data has changed since last accessed....

    And show them what he change was.....
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Feb 2004
    Location
    Rhode Island
    Posts
    69
    thanks Brett,
    Masanam

Posting Permissions

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