如果是插入记录,可以不用循环insert into t(字段1,字段2)
select 0,1
union all
select 1,2
.....
select 0,1
union all
select 1,2
.....
解决方案 »
- SQL Server安装问题 急啊```在线等````````````````````````````````````
- Windows不能在本地计算机启动 SQL Server(MSSQLSERVER)。
- 数据类型如果是VARCHAR类型,则末尾莫名其妙出现一个空格和回车换行符号,总长度+2?这个 "空格和回车换行符" 是怎么进去的?
- 请问,sql server需要加密吗?是如何加密的,加密后对查询修改数据库的速度有多少影响?谢谢
- vc++ ado 多线程 访问远程数据库的疑惑。
- SQL大数据表条件搜索优化问题。
- 关于全文索引的问题
- 怎样在 在 SQL Server 2000 中的视图 创建索引?
- ***** 紧急求助!做过MSSQL中往DB2写数据的兄弟请进来!
- 急!我遇到一个oracle权限问题
- 求去重复SQL语句!谢谢!
- 帮我看看这个SQL问题,谢谢,急死了
while 条件
begin
语句
end
drop table [dbo].[temp3]create table temp3(字段1 int not null ,字段2 int not null)
godeclare @i int,@j int
select @i=0
while @i<=9
begin
set @j=0 while @j<=9
begin
insert into temp3 select @i,@j
set @j=@j+1
end
set @i=@i+1
end
select * from temp3
/*
字段1 字段2
0 0
0 1
0 2
0 3
0 4
0 5
0 6
0 7
0 8
0 9
1 0
1 1
1 2
1 3
1 4
1 5
1 6
1 7
1 8
1 9
2 0
2 1
2 2
2 3
2 4
2 5
2 6
2 7
2 8
2 9
3 0
3 1
3 2
3 3
3 4
3 5
3 6
3 7
3 8
3 9
4 0
4 1
4 2
4 3
4 4
4 5
4 6
4 7
4 8
4 9
5 0
5 1
5 2
5 3
5 4
5 5
5 6
5 7
5 8
5 9
6 0
6 1
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
7 0
7 1
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
8 0
8 1
8 2
8 3
8 4
8 5
8 6
8 7
8 8
8 9
9 0
9 1
9 2
9 3
9 4
9 5
9 6
9 7
9 8
9 9*/
select @i=0,@j=0while @i<=9
begin
while @j<=9
begin
insert into tb(col1,col2) values(@i,@j)
set @j=@j+1
end
set @i=@i+1
end大體上是這樣的﹐其他自己補充