emp1表
id name sal
4 hr 10000
5 crm 20000
emp表
id name sal
4 hr 10000
5 crm 20000
在运行以下查询时,我的emp1表正在生效 它不回滚..?任何人都可以帮助我
BEGIN TRAN T1
DELETE FROM EMP1 WHERE ID=5
DELETE FROM EMP WHERE ID=11
COMMIT TRAN T1
BEGIN
PRINT 'SUCCES FULLY DELETED'
ROLLBACK TRAN T1
END
如果任何陈述失败,预期的O / P不应对emp1和emp产生影响........
答案 0 :(得分:0)
也许你想要这样的事情发生?
begin try
BEGIN TRAN T1
DELETE FROM EMP1 WHERE ID=5
DELETE FROM EMP WHERE ID=11
COMMIT TRAN T1
PRINT 'SUCCES FULLY DELETED'
end try
begin catch
if @@trancount > 0
ROLLBACK TRAN T1
end catch