以下事务(一个简短的例子)将失败,但怎样让他显示“执行失败”呢(在查询分析器中)?
--以下事务将失败,但怎样让他显示“执行失败”呢?
begin tran
create table t1(a int);
create table t2(b int);
insert into t1 select 1000;
select * from t1
insert into t2 select 'abc'
select * from t2
if @@error =0 begin
select '执行成功'
commit tran
end else begin
select '执行失败'
rollback tran
end