http://expert.csdn.net/Expert/topic/2437/2437014.xml?temp=.67857
交流]自增号1: 自增列 类型为:int identity(1,1) 当然也可以是bigint,smallint
eg: create table tbName(id int identity(1,1),description varchar(20))
或在用企业管理器设计表字段时,将字段设为int,将标识设为是,其它用默认即可2: 查询时加序号:
a:没有主键的情形:
Select identity(int,1,1) as iid,* into #tmp from TableName
Select * from #tmp
Drop table #tmp
b:有主键的情形:
Select (Select sum(1) from TableName where KeyField <= a.KeyField) as iid,* from TableName a
交流]自增号1: 自增列 类型为:int identity(1,1) 当然也可以是bigint,smallint
eg: create table tbName(id int identity(1,1),description varchar(20))
或在用企业管理器设计表字段时,将字段设为int,将标识设为是,其它用默认即可2: 查询时加序号:
a:没有主键的情形:
Select identity(int,1,1) as iid,* into #tmp from TableName
Select * from #tmp
Drop table #tmp
b:有主键的情形:
Select (Select sum(1) from TableName where KeyField <= a.KeyField) as iid,* from TableName a
解决方案 »
- 本地连接数据库的代码怎么写?是本地连接,而不是远程连接。
- 别人问我的一个SQL题我弄了好久都没出结果求高手帮忙!!!
- 可以用SQL语句查询每天某个时间段内的记录吗?
- 再请帮忙看看为什么这个游标总是多执行一次?
- 明天就考试了,向大家请教几道题~~
- 怎么才能自动生成报表,又是怎么创建存储过程的呢
- 高分!不同系统间数据同步的工具,DTS行吗?
- jsp + SQL Server2000的连接问题
- 我是sqlserver菜鸟,问一个多表同步更新的问题
- 关于数据汇总查询的问题,紧急求助
- [求救!]exec方法中exec('update mytab set column1='+@ss)方法出错!!!~
- 简单视图问题
select * from #temp