simulate a block on the server for testing purposes

  • Hi all,

     

    How can I simulate a block on the server for testing purposes? I don't want to insert/update/add anything.

    I tried hinting a lock without commiting, while running second tran:

    QA WINDOW 1:

    begin tran

    SELECT * FROM dbo.CUSTOMERS with (XLOCK)

     

    QA Window 2:

    SELECT * FROM dbo.CUSTOMERS

     

    But that didn't hold a block, and came back very fast.

     

  • how about doing an update but wrapping it in a transaction?

    begin transaction

    update table set column = value

    --rollback transaction

    execute the begin and the update, try your select from another window, when you have proved your lock, execute the rollback

  • You could also try the second query with an exclusive lock in a transaction - same as the first. 

  • Thank you

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply