这句错在哪里update (select top 2 * from HPTraceCode where planid=15 and state='2' order by bodyCode DESC) set state='1'

寒雪叔叔 2005-10-07 08:23:01
我只想将符合条件的记录的前两条进行UPDATE操作
update (select top 2 * from HPTraceCode where planid=15 and state='2' order by bodyCode DESC) set state='1'
请问错在哪里,在SQL SERVER里不能执行,而在ACCESS里好象就可以
...全文
97 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
htz1977 2005-10-07
  • 打赏
  • 举报
回复
楼主,UPDATE 后面是先表 再写入的数据, 后面才是写条件的, 你把位置放反了,
zxbyhcsdn 2005-10-07
  • 打赏
  • 举报
回复
改Sql

update HPTraceCode
set state='1'
where id in (select top 2 id from HPTraceCode A where planid=15 and state='2' order by bodyCode DESC)

22,209

社区成员

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

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