SQL自动编号 通过select生成自增长列的办法 应用在各种SQL排名中
来源:互联网 发布:域名与二级域名 编辑:程序博客网 时间:2024/04/29 19:46
內容轉自:http://db001.com/webc/mssqld/20100730197.html
SQL自动编号 创建测试环境
create table test(id int,sort varchar(10))
SQL自动编号 插入测试数据
insert into test select 1,'a' union all select 2,'b' union all select 3,'c'union all select 4,'d'union all select 5,'e'
SQL自动编号 方法1 不借助临时表
select autoid =(select count(*) from test where id <= a.id),* from test a
SQL自动编号 查询结果
autoid id sort-----------------11a22b33c44d55e
SQL自动编号 方法2 借助临时表
select autoid=identity(int,1,1),* into # from test
SQL自动编号 方法2查询结果
select * from #----------------------autoid id sort-----------------11a22b33c44d55e
SQL自动编号 建议
实际应用中,建议使用方法1,这种一般应用在为各类排名中使用。
- SQL自动编号 通过select生成自增长列的办法 应用在各种SQL排名中
- 在select中添加排名列的SQL语句
- 自动生成自增长编号
- 在SQL Server2000中实现rowNumber功能:查询中生成自动增长列
- SQL SERVER 初始自动编号值,初始自增长值
- SQL自动增长列
- SQL设置自增长列的初始值
- Sql Server数据库自增长字段标识列的插入或更新修改操作办法
- SQL Server实现列的自动增长
- Sql 重置自动增长列
- SQL生成按月的自动编号
- sql获取自动生成的ID编号
- 如何在SQL中设置自动编号
- 在SQL 2000中实现自动编号
- 在SQL server中设置表的自动编号功能
- 在SQL server中设置表的自动编号功能
- 在SQL server中设置表的自动编号功能
- 在SQL server中设置表的自动编号功能
- To configure IMAP for your Symbian S60 device
- Dlg添加背景图片
- colorschememapping
- 操作系统开发系列——Bootloaders
- jstl 常用方法
- SQL自动编号 通过select生成自增长列的办法 应用在各种SQL排名中
- 【甜屋- The Sweety House】存在的bug与缺陷
- 最近使用存储过程的一定小东西总结下
- Ajax------------- spring+dwr整合
- 集成单元测试google test (转载)
- Spring定时器
- UDP 穿透NAT解析 TCP 穿透NAT解析
- 常用电容器
- oracle union union all intersect minus