sql語句rollback sql server中的update語句回滾怎么寫???
sql server中的update語句回滾怎么寫?。恐挥袑⑵浞湃胧聞?wù)中時才能執(zhí)行回滾。Transaction1:可以使用try catch捕獲begin try begin tran update
sql server中的update語句回滾怎么寫?。?/h2>
只有將其放入事務(wù)中時才能執(zhí)行回滾。Transaction1:可以使用try catch捕獲begin try begin tran update table set a=1;commit tranend trybegin catch rollback tranend CATCH2:可以使用error全局變量begin tranupdate tablename set ad=1111if@@error0 begin rollback Endcommit tran注意:如果事務(wù)寫入begin trans,它必須后跟commit tran或rollback transaction,否則可能會被鎖定