一道SQL试题,写条SQL语句

来源:百度知道 编辑:UC知道 时间:2024/06/04 05:35:58
、现有一个表table1只有一个字段F1,表中数据如下:
Z0001
0
1
2
3
4
5
6
7
8
9
问题:用现有的数据用一个SQL语句构造出一个1-9999的结果集,类似如下:
1
2

... ...
9999
******************不要用脚本**************

select F1 from table
union select 1||F1 as F1 from table
...
依次类推

这是思路 我先试验下

这思路不行

declare @tempTable table(Z0001 int)

begin
declare @i int
set @i=0
while(@i<10000)
begin
insert into @tempTable(Z0001) values (@i)
set @i=@i+1
end
end
select * from @tempTable

结果集用union

什么叫不用脚本。。。。

没看懂