首页 > 数据库 >sqlserver生成测试数据

sqlserver生成测试数据

时间:2023-03-02 15:12:56浏览次数:43  
标签:RAND set end batchSize sqlserver 测试数据 生成 beginTime

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

标签:RAND,set,end,batchSize,sqlserver,测试数据,生成,beginTime
From: https://www.cnblogs.com/zjb480/p/17171805.html

相关文章