begin tran --트랜잭션 시작
commit tran --트랜잭션 완료
rollback tran --트랜잭션 취소
select @@error --에러 count
CREATE proc tran01
@tbname varchar(10),
@types varchar(5),
@comment varchar(20)
AS
begin tran
INSERT tableinfo(tbname, comment, types)
VALUES(@tbname, @comment, @types)
IF @@error>0 --오류가 발생하면
begin
print '오류방생!'
rollback tran
end
else
begin
print '제대로 실행!'
commit tran
end
exec tran01 'aaa','board','테스트'