22,300
社区成员




create table TT(ID numeric(10),name char(20),Englist numeric(5,2),physics numeric(5,2));
go
alter proc tpro
as
begin tran
insert into TT(ID,name,Englist,physics) values(3,'张三',89,98);
commit tran
go
go
begin tran
declare @II int;
set @II=1;
while @II<10000
begin
exec tpro;
end;
commit tran
go
select COUNT(*) from TT;
--我的天啦,8分钟还没有完,我只有中止执了....也不知要多久..
--大家有没有更快的办法
set nocount on
begin tran
declare @II int;
set @II=1;
while @II<10000
begin
exec tpro;
set @II=@II+1
end;
commit tran
set nocount off
begin tran
insert into TT(ID,name,Englist,physics) values(3,'张三',89,98);
commit tran
IF @@TRANCOUNT > 0 COMMIT TRAN
执行几次把没有提交的事务提交上去set nocount on
begin tran
declare @II int;
set @II=1;
while @II<10000
begin
exec tpro;
end;
commit tran
set nocount off
begin tran
declare @II int;
set @II=1;
while @II<10000
begin
exec tpro;
--add
set @II=@II+1;
end;
commit tran
while @II<10000
begin
exec tpro;
set @II = @II + 1
end;