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. how to unloch table in sql

how to unloch table in sql

Scheduled Pinned Locked Moved Database
databasehelptutorial
6 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.
  • M Offline
    M Offline
    mhd sbt
    wrote on last edited by
    #1

    hi to all i lock a table in sql with belwo query

    begin tran
    select * from BML.LoanApplication with(TABLOCKX)

    now i want to unlock this table but i cant . i can read from this table by nolock but i want to unlock this table any help can be usefule

    L C 2 Replies Last reply
    0
    • M mhd sbt

      hi to all i lock a table in sql with belwo query

      begin tran
      select * from BML.LoanApplication with(TABLOCKX)

      now i want to unlock this table but i cant . i can read from this table by nolock but i want to unlock this table any help can be usefule

      C Offline
      C Offline
      Corporal Agarn
      wrote on last edited by
      #2

      commit tran

      1 Reply Last reply
      0
      • M mhd sbt

        hi to all i lock a table in sql with belwo query

        begin tran
        select * from BML.LoanApplication with(TABLOCKX)

        now i want to unlock this table but i cant . i can read from this table by nolock but i want to unlock this table any help can be usefule

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        First of all, locking has little use when selecting. Second, the lock is released as soon as the statement completes. What did you think it does?

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        M 1 Reply Last reply
        0
        • L Lost User

          First of all, locking has little use when selecting. Second, the lock is released as soon as the statement completes. What did you think it does?

          Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

          M Offline
          M Offline
          mhd sbt
          wrote on last edited by
          #4

          ok but this is when that you use COMMIT end of my related code. but i dont use COMMIT tran in my code. and if use this code you can see that this table is lock:

          select * from sys.dm_tran_locks inner join sys.objects on sys.dm_tran_locks.resource_associated_entity_id=sys.objects.[object_id]

          L 1 Reply Last reply
          0
          • M mhd sbt

            ok but this is when that you use COMMIT end of my related code. but i dont use COMMIT tran in my code. and if use this code you can see that this table is lock:

            select * from sys.dm_tran_locks inner join sys.objects on sys.dm_tran_locks.resource_associated_entity_id=sys.objects.[object_id]

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            mehdi.sabet wrote:

            ok but this is when that you use COMMIT end of my related code.
            but i dont use COMMIT tran in my code.

            First, it's a lousy example; there's no way that the server can "guess" whether it should be rolled back or comitted automatically. Second, there is nothing to commit or rollback, since a SELECT statement doesn't change the data. Don't use a transaction when selecting. Also, set [XACT ABORT](http://msdn.microsoft.com/en-us/library/ms188792.aspx)[[^](http://msdn.microsoft.com/en-us/library/ms188792.aspx "New Window")] to ON. Also, don't lock an entire table, unless really, really required.

            mehdi.sabet wrote:

            and if use this code you can see that this table is lock:

            Code to close it on SO[^]

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

            M 1 Reply Last reply
            0
            • L Lost User

              mehdi.sabet wrote:

              ok but this is when that you use COMMIT end of my related code.
              but i dont use COMMIT tran in my code.

              First, it's a lousy example; there's no way that the server can "guess" whether it should be rolled back or comitted automatically. Second, there is nothing to commit or rollback, since a SELECT statement doesn't change the data. Don't use a transaction when selecting. Also, set [XACT ABORT](http://msdn.microsoft.com/en-us/library/ms188792.aspx)[[^](http://msdn.microsoft.com/en-us/library/ms188792.aspx "New Window")] to ON. Also, don't lock an entire table, unless really, really required.

              mehdi.sabet wrote:

              and if use this code you can see that this table is lock:

              Code to close it on SO[^]

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

              M Offline
              M Offline
              mhd sbt
              wrote on last edited by
              #6

              ok thankue

              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