希望对你咐竖有帮助衡迟大if exists(select 1 from sysobjects where name='proc_insert')
drop procedure proc_insert
gocreate procedure proc_insert
@number2 varchar(20),
@number3 varchar(20)
as
begin transaction
declare @errornum int,@number varchar(30)
set @errornum=0 insert into tb1 values(@number2,@number3) set @errornum=@errornum+@@error
set @number=@number2+CONVERT(varchar(20),@@identity) --CAST(@@identity AS varchar(30)) insert into tb2 values(@number,@number3)
set @errornum=@errornum+@@error if @errornum<>0
begin
rollback transaction
end
else
begin
commit transaction
end
goexec proc_insert 'qwe','旦乱123'
如果使用oracle9i就可以,例返芹昌漏扒首模如:insert all
into insert_all_test1 values(no,name)
into insert_all_test2 values(no,sal)
select empno no,ename name,sal from scott.emp;
标准之所以叫做T-SQL,因为这个T指的是事务处理。SO,要在存储过程里配合事务处理来做。
为什么不分开执行?
这个可以使用触发器完成