exec sp_executesql N' SET FMTONLY OFF; SET NO_BROWSETABLE ON; DECLARE @icount INT
SET NOCOUNT ON
SET @icount=0
DECLARE @OutIdTable TABLE (Id BIGINT)
DECLARE @lastValue INT
DECLARE @trancount int
set @trancount=@@TRANCOUNT
if @trancount>0
save transaction sp
else
begin transaction
begin try
if @count<=100
begin
WHILE @icount<@count
BEGIN
INSERT INTO Z_HC_COLLECTDISKIO
( Column1 )
VALUES ( 0 -- Column1 - int
);
INSERT INTO @OutIdTable
( Id )
VALUES (SCOPE_IDENTITY());
SET @icount=@icount + 1
END
SELECT id FROM @OutIdTable;
end
else
begin
update Z_HC_COLLECTDISKIO with(tablock) set Column1=Column1;
exec sp_executesql N''insert into Z_HC_COLLECTDISKIO(column1)
select top(@count) 1 from master..spt_values x cross join master..spt_values y'',N''@count int'',@count=@count;
select id from Z_HC_COLLECTDISKIO with(tablock);
end
if @trancount>0
rollback transaction sp
else
rollback transaction
end try
begin catch
if @trancount>0
rollback transaction sp
else
rollback transaction
declare @errmessage nvarchar(4000)
declare @errserverity int
declare @errstate int
select @errmessage=ERROR_MESSAGE(),@errserverity=ERROR_SEVERITY(),@errstate=ERROR_STATE()
raiserror(@errmessage,@errserverity,@errstate)
end catch
',N'@count int',@count=1