当前位置: 数据库>sqlserver
SQLServer 循环批处理
来源: 互联网 发布时间:2014-09-05
本文导语: 下面方法可以用来快速生成一批数据 if(object_id('t') is not null) drop table t go create table t(id int identity(1,1),name varchar(40)) go insert into t(name) select newid() go 10 select * from t /* 1 18C1C418-9029-4599-8D5E-616354A113C8 2 A0FE1177-09D8-4C56-9FB5-C2FAFF0155CF 3 9033...
下面方法可以用来快速生成一批数据
if(object_id('t') is not null) drop table t
go
create table t(id int identity(1,1),name varchar(40))
go
insert into t(name) select newid()
go 10
select * from t
/*
1 18C1C418-9029-4599-8D5E-616354A113C8
2 A0FE1177-09D8-4C56-9FB5-C2FAFF0155CF
3 9033E8BB-B9A4-4A08-83D8-40064AB68C5F
4 A179A300-E30B-42BF-974E-50928EB7DCF1
5 C1D36D3B-C4D7-431B-8C81-95C9EF9061A0
6 8A99066A-7993-4C06-9763-482C0BF5E687
7 2F0664A8-F91D-4BDE-BA0B-48624137B7CA
8 74C3FED3-6182-4ED9-9BFE-9C3DEC662F35
9 4E7A8CC8-D7CE-4A0D-8562-688FB3F91458
10 EC82BD91-20B3-46C1-B7CC-C4A8A9099376
*/
if(object_id('t') is not null) drop table t
go
create table t(id int identity(1,1),name varchar(40))
go
insert into t(name) select newid()
go 10
select * from t
/*
1 18C1C418-9029-4599-8D5E-616354A113C8
2 A0FE1177-09D8-4C56-9FB5-C2FAFF0155CF
3 9033E8BB-B9A4-4A08-83D8-40064AB68C5F
4 A179A300-E30B-42BF-974E-50928EB7DCF1
5 C1D36D3B-C4D7-431B-8C81-95C9EF9061A0
6 8A99066A-7993-4C06-9763-482C0BF5E687
7 2F0664A8-F91D-4BDE-BA0B-48624137B7CA
8 74C3FED3-6182-4ED9-9BFE-9C3DEC662F35
9 4E7A8CC8-D7CE-4A0D-8562-688FB3F91458
10 EC82BD91-20B3-46C1-B7CC-C4A8A9099376
*/