SQL neeg rau zaub mov 2005 tshiab khiv intoduced rau txoj kev rollback rau muas hauv SQL neeg rau zaub mov 2005
SET XACT_ABORT RAU
Thaum XACT_ABORT yog ib tug. Lub T-SQL ntawv yuav txiav rollback tus lw thaum yuam kev tshwm sim nyob rau hauv nqe lus.
SET XACT_ABORT RAU
SIV Emp
Pib Tran
Ntxig rau hauv EmpInfo qhov tseem ceeb(1)
Ntxig rau hauv EmpInfo qhov tseem ceeb(1) — Tsab ntawv no yuav ua kom cov neeg yuam kev tseem ceeb
Ntxig rau hauv EmpInfo qhov tseem ceeb(2)
Kuas nyuas siv zug muaj Tran
Rau thawj kab kev cai yuav txim tuag yog tias tsis muaj cov uas tsis. Cov thawj tseem ceeb yuam kev yuav sawv nyob hauv kab thib ob. Tiam sis tus thaiv tas nrho tham tsis yuav commited vim XACT_ABORT nyob rau.
Koj yuav tsum nco ntsoov tas sij tias XACT_ABORT hawm cov chaw * batch *, qhov hais kom ua tag nrho tsis. Cooling muaj cais nrog cov lo lus tseem ceeb mus. Tiav yuav pib ntawm tus tom ntej batch.
No feature tseem nyob rau SQL tus neeg rau zaub mov 2000, tab sis yog nws behaves ib nyuag txawv rau ntau yam uas tsis.
Nyob rau hauv SQL 2000, yog mob qhov twg XACT_ABORT tsis rollback txoj lw txiav.
Piv txwv:
Inserting rau hauv ib tug lub npe invalid sab.
Inserting ua ib qhov tseem ceeb thawj cov IDENTITY_INSERT tawm.
Executing xaiv uas siv ib tug tsis-existent UDF.
Cov uas tsis yog feem ntau thaum ib tug tsis authored hais kom ua, kom lawv tsis txhob tshwm hauv lub lag luam ntawm koj cov kev pab cuam cov num tshwj tsis yog ib tug neeg alters lub schema. Tiam sis nws muaj kev pab dab tsi rau lawv ploj thaum authoring database hloov tshiab scripts thaum deploying ib version tshiab ntawm ib qhov project, just hais txiag tsis mus li los.
Muaj ntau txoj kev los lis cov uas tsis. Koj ua phem no yuav tsum tau nyob rau hauv cov batch ua tau zoo rau cov nqe lus DML. Tom qab cov batch (tom qab cov lo lus tseem ceeb mus) kos lub @@TRANCOUNT puas yog nws tseem ntau dua zero thiab ua raws li. Feem ntau yog ROLLBACK tus lw.
Muas tau ntsua kev cooling, ces koj yuav coj ib tug rollback nyob hauv ib tus tom batch.