很难的问题,但很实用,我的同事的

roapzone 2003-12-23 07:05:57
能不能在SELECT语言结果集中产生记录号???
...全文
54 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
roapzone 2003-12-26
  • 打赏
  • 举报
回复
多谢这么多的热心的程序员的回帖
!!
j9988 2003-12-23
  • 打赏
  • 举报
回复
有标识号就好办了

select (select count(*) from Yourtab where 标识列<=A.标识列) as ORD,* from Yourtab A
roapzone 2003-12-23
  • 打赏
  • 举报
回复
to dlpseeyou(豆子)
你要清掉临时表
dlpseeyou 2003-12-23
  • 打赏
  • 举报
回复
select *,identity(int,1,1) as id into #t from Tablename
select * from #t
roapzone 2003-12-23
  • 打赏
  • 举报
回复
to sdhdy(大江东去...)
不好意思,我的语句写错误了
你的语句写的可以
能不能不用临时表???
roapzone 2003-12-23
  • 打赏
  • 举报
回复
to sdhdy(大江东去...)
服务器: 消息 8108,级别 16,状态 1,行 1
无法使用 SELECT INTO 语句向表 '#temp' 中添加标识列,该表中已有继承了标识属性的列 'row_id'。
solidpanther 2003-12-23
  • 打赏
  • 举报
回复
select *,identity(int,1,1) as id into #t from Tablename
select * from #t
drop table #t
roapzone 2003-12-23
  • 打赏
  • 举报
回复
就像
行号 column1
1 abc
2
3
4
5
6

sdhdy 2003-12-23
  • 打赏
  • 举报
回复
select identity(int,1,1) FID,* into #temp from tablename where ...
select * from #temp
drop table #temp

22,209

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server 疑难问题
社区管理员
  • 疑难问题社区
  • 尘觉
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧