SQL code--================================================
--绕圈的SQL算法(感觉很笨,不知道有没有更好的算法)
--作者:jht
--日期:2008-02-21
--执行方式(参数必须为整数的平方,但大小并不是无限制的)
--set a = 20
--================================================
declare @a int,@k int,@s varchar(1000),@i int
declare @r int,@c int,@rf int,@cf int
select @a=20,@k = 0
create table # (id int)
while @k < @a
begin
insert #(id) select @k
set @s = 'alter table # add c'+rtrim(@k)+' int' exec(@s)
set @k = @k +1
end
select @r =-1,@c = 0,@rf = 1,@cf = 0,@i = 0
while @a > 0
begin
set @k = 0
while @k
转载于:https://www.cnblogs.com/y0umer/archive/2009/06/23/3839484.html