如何查询出第N条记录,N为任一常量??

flashasp 2003-08-18 08:51:14
RT
...全文
22 16 打赏 收藏 转发到动态 举报
写回复
用AI写文章
16 条回复
切换为时间正序
请发表友善的回复…
发表回复
ysycrazy 2003-08-19
  • 打赏
  • 举报
回复
不是让你去改,只要让你原来的标识列不显示出来即可。如下:

select IDENTITY(int, 1,1) AS ID,除原来表里面的标识列外的所有列 into #temp from 表
select * from #temp where ID=任意常量

flashasp 2003-08-19
  • 打赏
  • 举报
回复
关键是我的程序不能再去改取标志列的啦!
flashasp 2003-08-19
  • 打赏
  • 举报
回复
现在关键就是我的程序不能取标志列!
chao778899 2003-08-19
  • 打赏
  • 举报
回复
取标志列的问题,如果没有标志列就要自己建标志列,建好了就一切OK了
ysycrazy 2003-08-19
  • 打赏
  • 举报
回复
问题简单,你只要去掉原来表里面的标识列即可。更正如下:
select IDENTITY(int, 1,1) AS ID,除原来表里面的标识列外的所有列 into #temp from 表
select * from #temp where ID=任意常量
yujohny 2003-08-19
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from result
select * from #temp where ID_Num=10
----------------------------------------用此法报错:

服务器: 消息 8108,级别 16,状态 1,行 1
无法使用 SELECT INTO 语句向表 '#temp' 中添加标识列,该表中已有继承了标识属性的列 'id'。

这个错误就是要你定义临时表中的ID字段时候不要设为IDENTITY(int, 1,1),明白吗?
flashasp 2003-08-19
  • 打赏
  • 举报
回复
select (select sum(1) from yourtable where id<=AA.id) as row, * from yourtable as AA where row=任意常量

服务器: 消息 207,级别 16,状态 3,行 1
列名 'row' 无效。
---------------------------------------------
dafu71 2003-08-19
  • 打赏
  • 举报
回复
select (select sum(1) from yourtable where id<=AA.id) as row, * from yourtable as AA where row=任意常量
dafu71 2003-08-19
  • 打赏
  • 举报
回复
select (select sum(1) from yourtable where id<=AA.id) as row, * into from yourtable as AA where row=任意常量

flashasp 2003-08-19
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from result
select * from #temp where ID_Num=10
----------------------------------------用此法报错:

服务器: 消息 8108,级别 16,状态 1,行 1
无法使用 SELECT INTO 语句向表 '#temp' 中添加标识列,该表中已有继承了标识属性的列 'id'。

flashasp 2003-08-19
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
select * from #temp where ID_Num=10
------------------------------------------------我用此法报错啊!

服务器: 消息 8108,级别 16,状态 1,行 1
无法使用 SELECT INTO 语句向表 '#temp' 中添加标识列,该表中已有继承了标识属性的列 'id'。
happy_0325 2003-08-19
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID,* into #temp from 表
select * from #temp where ID=任意常量
ysycrazy 2003-08-19
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID,* into #temp from 表
select * from #temp where ID=任意常量
benxie 2003-08-18
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
select * from #temp where ID_Num=10
pengdali 2003-08-18
  • 打赏
  • 举报
回复
select IDENTITY(int, 1,1) AS ID_Num,* into #temp from 表
select * from #temp where ID_Num=10
hjb111 2003-08-18
  • 打赏
  • 举报
回复
select identity(int,1,1) idd ,* into #t from yourtable
select * from #t where idd=n
drop table #t

34,576

社区成员

发帖
与我相关
我的任务
社区描述
MS-SQL Server相关内容讨论专区
社区管理员
  • 基础类社区
  • 二月十六
  • 卖水果的net
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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