sqlserver生成测试数据

Checkpoint-----flush data to disk
Dbcc dropcleanbuffers -----drop data cache
create table t2(id int not null identity (1,1),dystr varchar(200),fixstr char(500));
go
declare @beginTime datetime,@endTime datetime
set @beginTime=GETDATE()

set nocount on

declare @batchSize int
set @batchSize=1000
declare @i int
set @i=0
while(@i<2000000)
begin
if (@i%@batchSize=0)
begin
if (@@TRANCOUNT>0)COMMIT TRAN
BEGIN TRAN
end

insert into t2(dystr,fixstr)values('aaa'+str(RAND()*100000000),'bbb'+str(RAND()*100000000))
set @i=@i+1

end
if (@@TRANCOUNT>0)COMMIT TRAN
select @endTime-@beginTime

posted @ 2023-03-02 14:56  zjb480  阅读(80)  评论(0)    收藏  举报