create table tb (num int identity(1,1),name varchar(10))
declare @a varchar(10)
set @a='A'
while @a<'Z'
begin
insert into tb values (@a)
set @a=CHAR(ASCII(''+@a+'')+1)
end
--select * from tb
--版本什么的好像不要,无论什么版本只要输入的最大@id不超过该版本支持的最大行数就可以
declare @id int
set @id=5
;with cte
as(select ROW_NUMBER() over (order by len(name),name) as id,name from
(select name from tb
union all
select a.name+b.name from tb a,tb b) a)
select name from cte where id<=@id
--其实就是简化为如下
;with cte
as(select ROW_NUMBER() over (order by len(name),name) as id,name from
(select name from tb
union all
select a.name+b.name from tb a,tb b) a)
select name from cte where id<=10000--随便自己输入
name
--------------------
A
B
C
D
E
------解决方案-------------------- 给力。
------解决方案-------------------- 学习 ~
------解决方案-------------------- 额。。。来啦
------解决方案--------------------
------解决方案-------------------- 分数给力能力不行 来接分吧
------解决方案-------------------- [code=SQL][/code] -- ============================================= -- Create scalar function (FN) -- ============================================= IF EXISTS (SELECT * FROM sysobjects WHERE name = N'GetExcelColumnTitle') DROP FUNCTION GetExcelColumnTitle