Results 1 to 9 of 9

Thread: Locks

  1. #1
    Join Date
    Nov 2003
    Location
    Mars
    Posts
    115

    Unanswered: Locks

    Hi All,
    Sql server 7

    pls provide me sql statement that shows all the locks. the goal is to produce the output on an HTML page.

    pls help me in solving this

    TIA
    Adil

  2. #2
    Join Date
    Feb 2002
    Posts
    2,232
    sp_lock

  3. #3
    Join Date
    Nov 2003
    Location
    Mars
    Posts
    115

    lock

    Hi thanks for ur reply,

    Main concern is there any way how i can automatically kill the blocked process or there is any stored procedure which will help me killing that session.

    TIA
    Adil

  4. #4
    Join Date
    Feb 2002
    Posts
    2,232
    kill

  5. #5
    Join Date
    Nov 2003
    Location
    Mars
    Posts
    115
    kill spid would kill it tnks, i want to know if i can kill it automatically or any stored tht would help me do it.

    Thanks once again

  6. #6
    Join Date
    Feb 2002
    Posts
    2,232
    Describe the scenario where you would need to kill a spid - normally problems like the one you are trying to solve by killing should be solved by making database design/query changes.

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Gotta be careful...you'll wind up with an Orphanage...


    If you've got blocking, you need to change your code....
    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.

  8. #8
    Join Date
    Nov 2003
    Location
    Mars
    Posts
    115
    I want to know if we can create a kill command that works automatically, since it could be a different SPID that's locked. Or do you know of a stored procedure that can kill any offending SPID?

  9. #9
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You can wrap a cursor around the last sql and execute the kills...

    I would think you'd need to kill the blockee and the blocker...

    I DONT reccomend this...

    Code:
    CREATE TABLE CurrentBlocks (
    	  spid		int
    	, ecid		int
    	, status	varchar(255)
    	, loginame	varchar(255)
    	, hostname	varchar(255)
    	, blk		int
    	, dbname	varchar(255)
    	, cmd		varchar(255)
    )
    GO
    
    INSERT INTO CurrentBlocks (spid, ecid, status, loginame, hostname, blk, dbname, cmd)
    EXEC sp_who
    GO
    
    SELECT spid, blk 
      FROM CurrentBlocks
     WHERE blk <> 0
    GO
    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.

Posting Permissions

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