我有这样的查询:
我想更新表格中的最后50条记录
所以我写了一个这样的查询
update transaction_tbl
set dtime = '2014-04-16 14:15:47.243'
where transactid in (select top (50) from transaction_tbl order by transactid desc)
执行此操作时出现此错误
关键字'from'
附近的语法不正确
我的查询有什么问题?我该如何解决这个问题?
我正在使用SQL Server 2008.感谢任何帮助。
答案 0 :(得分:3)
将列名添加到子查询:
update transaction_tbl set dtime='2014-04-16 14:15:47.243'
where transactid in (select top (50) transactid from transaction_tbl order by transactid desc)