---------------生成1-100数字的方法(包括SQL SERVER和DB2)----------
2014-12-31 16:34
357 查看
--1.while declare @t table (id int) declare @i int set @i=1 while @i<101 begin insert into @t select @i set @i=@i+1 end select * from @t --2. goto declare @t1 table (id int) declare @j int set @j=1 f: insert into @t1 select @j set @j=@j+1 if(@j<101) goto f select * from @t1 --3.identity+临时表 select top 100 identity(int,1,1) id into #tmp from syscolumns,sysobjects select id from #tmp; drop table #tmp --4.row_number() select top 100 row_number() over(order by (select 1)) from syscolumns,sysobjects --5.系统辅助表master..spt_values select number from master..spt_values where type='p' and number between 1 and 100 --6.CTE递归 ;with cte as ( select 1 id union all select cte from t where id<100 ) select * from t --7.用0-9做序列 ;with f as ( select 0 id union select 1 union select 2 union select 3 union select 4 union select 5 union select 6 union select 7 union select 8 union select 9 ) select a.id+b.id+1 id from m a ,(select id*10 id from m) b 附上DB2的方法: select row_number()over(order by (values 1)) as a from sysibm.sysdummy1,sysibm.syscoulmns fetch first 100 rows only;
相关文章推荐
- 自动生成1到100的数字自增序列的几种方法
- 生成一组指定范围内随机数(取50个数字,100到200的随机数字) LINQ方法
- DB2生成数字序列的两种方法
- sql server 提取汉字/数字/字母的方法
- [转] SQL Server自动生成日期加数字的序列号
- C#随机生成n位数字和字母的方法
- [C#]生成一串包含字符和数字的随机字符串的方法
- SQL Server中导入/导出 Excel (包括SQL实现和Net代码实现)的基本方法
- SQL SERVER中 利用方法生成流水号
- SQL Server自动生成日期加数字的序列号
- SQL Server自动生成日期加数字的序列号
- Access和sql server的语法区别 (包括db2 oracle)
- 跨平台生成windows Excel二进制报表方法(包括中文支持)
- Sql Server 生成连续日期的方法总结 本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/GRANDTREE/archive/2009/06/16/4273129.aspx
- java生成数字证书方法
- SQL Server自动生成日期加数字的序列号
- Sql Server建表时设置双主键及列名以数字开头的解决方法
- java生成数字证书方法
- 常用方法一:随机数生成、检测非法字符、判断数字格式、是否为空、枚举值转化为数组
- NetcfSvcUtil生成的WCF代理类保存数字类型到Server端总为0问题解决方法