简体   繁体   中英

Blocked data after transaction

I wanted to do some update on a table (which one we could name "table1") and I wanted to use a transaction because of our production server.

I wrote a script like this :

BEGIN TRANSACTION T1

UPDATE table1 SET ...

SELECT * FROM table1 WHERE ...

And as you can see I forgot the commit/rollback statement.

After that I wanted to do another select on this table and I got a query timeout error.

I guessed that my transaction was blocking my table so I did another time the exact same transaction but this time with a commit statement.

But my table still blocked and I don't know how to commit/rollback the first waiting transaction.

I also tried to write a new query with just "COMMIT TRANSACTION T1" but I got an error telling me that the COMMIT statement need a corresponding BEGIN statement.

How can I do this ?

The session where you ran the first query is still active. If you ran this via SSMS then run the Commit\\Rollback from there with that session. If you can't find it then use the Activity Monitor or sp_who2 or other type method to locate the session and kill it.

You cannot modify the transaction on another session.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM