insert tablename (a,b) select a,b from ( select 1 as a union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all select 10 ) as t1,( select 1 as b union all select 2 union all select 3 union all select 4 union all select 5 union all select 6 union all select 7 union all select 8 union all select 9 union all select 10 ) as t2
if object_id('tempdb..#tmp') is not null drop table #tmp declare @t table(A int,B int) select top 10 id = identity(int,1,1) into #tmp from syscolumns insert @t select b.id ,a.id from #tmp a,#tmp b select * from @t drop table #tmp
declare @i int declare @j int set @i=1 set @j=1while(@i<=10 and @j<=10) begin insert into table1 values(@i,@j) print @i if(@j=10) begin set @j=1 set @i=@i + 1 end else set @j=@j+1 end
declare @i as int declare @j as int @i=1 @j=1while @i begin while @j begin insert into [table_name] (a,b) values(i,j) if @j=10 break else @j=@j+1 continue end if @i=10 break else @i=@i+1 continue end
declare @i as int declare @j as int @i=1 @j=1while @i begin while @j begin insert into [table_name] (a,b) values(i,j) if @j=10 break else @j=@j+1 continue end if @i=10 break else @i=@i+1 continue end有语法错误:服务器: 消息 156,级别 15,状态 1,行 11 在关键字 'begin' 附近有语法错误。 服务器: 消息 156,级别 15,状态 1,行 13 在关键字 'begin' 附近有语法错误。 服务器: 消息 170,级别 15,状态 1,行 19 第 19 行: '@j' 附近有语法错误。 服务器: 消息 170,级别 15,状态 1,行 25 第 25 行: '@i' 附近有语法错误。
declare @i int declare @j int set @i=1 set @j=1while(@i<=10 and @j<=10) begin insert into table1 values(@i,@j) print @i if(@j=10) begin set @j=1 set @i=@i + 1 end else set @j=@j+1 end 插不进入结果啊..
declare @i int declare @j int set @i=1while(@i<=10) begin set @j=1 while(@j<=10) begin insert into table1 values(@i,@j) set @j=@j+1 end set @i=@i+1 end
select a,b
from (
select 1 as a
union all
select 2
union all
select 3
union all
select 4
union all
select 5
union all
select 6
union all
select 7
union all
select 8
union all
select 9
union all
select 10
) as t1,(
select 1 as b
union all
select 2
union all
select 3
union all
select 4
union all
select 5
union all
select 6
union all
select 7
union all
select 8
union all
select 9
union all
select 10
) as t2
drop table #tmp
declare @t table(A int,B int)
select top 10 id = identity(int,1,1) into #tmp from syscolumns
insert @t select b.id ,a.id from #tmp a,#tmp b
select * from @t
drop table #tmp
declare @j int
set @i=1
set @j=1while(@i<=10 and @j<=10)
begin
insert into table1 values(@i,@j)
print @i
if(@j=10)
begin
set @j=1
set @i=@i + 1
end
else
set @j=@j+1
end
declare @j as int
@i=1
@j=1while @i
begin
while @j
begin
insert into [table_name] (a,b) values(i,j)
if @j=10
break
else
@j=@j+1
continue
end
if @i=10
break
else
@i=@i+1
continue
end
declare @j as int
@i=1
@j=1while @i
begin
while @j
begin
insert into [table_name] (a,b) values(i,j)
if @j=10
break
else
@j=@j+1
continue
end
if @i=10
break
else
@i=@i+1
continue
end有语法错误:服务器: 消息 156,级别 15,状态 1,行 11
在关键字 'begin' 附近有语法错误。
服务器: 消息 156,级别 15,状态 1,行 13
在关键字 'begin' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 19
第 19 行: '@j' 附近有语法错误。
服务器: 消息 170,级别 15,状态 1,行 25
第 25 行: '@i' 附近有语法错误。
declare @j int
set @i=1
set @j=1while(@i<=10 and @j<=10)
begin
insert into table1 values(@i,@j)
print @i
if(@j=10)
begin
set @j=1
set @i=@i + 1
end
else
set @j=@j+1
end
插不进入结果啊..
declare @j int
set @i=1while(@i<=10)
begin
set @j=1
while(@j<=10)
begin
insert into table1 values(@i,@j)
set @j=@j+1
end
set @i=@i+1
end