Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. SQL Server row lock

SQL Server row lock

Scheduled Pinned Locked Moved Database
tutorialdatabasesql-serversysadminhelp
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    Tridip Bhattacharjee
    wrote on last edited by
    #1

    How to row lock in SQL Server 2005. I execute a sql for row locking and that is SELECT * FROM authors WITH (HOLDLOCK, ROWLOCK) WHERE au_id = '274-80-9391' it work fine but in this case row is lock for update not for selection. I just want to know how to lock a row as a result another user can not see that row when issue a SQL in SQL Server. please guide me. thanks

    tbhattacharjee

    P D 2 Replies Last reply
    0
    • T Tridip Bhattacharjee

      How to row lock in SQL Server 2005. I execute a sql for row locking and that is SELECT * FROM authors WITH (HOLDLOCK, ROWLOCK) WHERE au_id = '274-80-9391' it work fine but in this case row is lock for update not for selection. I just want to know how to lock a row as a result another user can not see that row when issue a SQL in SQL Server. please guide me. thanks

      tbhattacharjee

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Bad news there, I'm afraid. You can't rowlock an row for a select in SQL Server 2005 so that others can't see it. Even the xlock hint won't cut it for you because it works as a page lock rather than a row lock in SQL Server 2005 and, if SQL Server determines that the underlying rows haven't changed, it will allow the read of the data.

      I'm not a stalker, I just know things. Oh by the way, you're out of milk.

      Forgive your enemies - it messes with their heads

      My blog | My articles | MoXAML PowerToys | Onyx

      1 Reply Last reply
      0
      • T Tridip Bhattacharjee

        How to row lock in SQL Server 2005. I execute a sql for row locking and that is SELECT * FROM authors WITH (HOLDLOCK, ROWLOCK) WHERE au_id = '274-80-9391' it work fine but in this case row is lock for update not for selection. I just want to know how to lock a row as a result another user can not see that row when issue a SQL in SQL Server. please guide me. thanks

        tbhattacharjee

        D Offline
        D Offline
        David Mujica
        wrote on last edited by
        #3

        If you are using SQL Server, you may want to investigate implementing your own locking logic by using sp_applock. Check this out ... http://msdn.microsoft.com/en-us/library/aa933410(SQL.80).aspx[^]

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups