我写的查询是:
delete from featured where featuredID IN(
select top(@removeAmnt) * from featured
order by featured.createdon asc)
似乎不起作用。我得到的错误是,“当EXISTS没有引入子查询时,只能在选择列表中指定一个表达式。”我不熟悉sql查询。我基本上试图通过他们的createdon字段来命令这些字段的默认值是日期函数。另外,sp允许传入值removeAmnt,这是将从顶部选择要删除的表条目数。
答案 0 :(得分:2)
您很可能需要删除*
:
delete from featured where featuredID IN(
select top(@removeAmnt) featuredID from featured
order by featured.createdon asc)
答案 1 :(得分:0)
你没有提到你得到的结果,但你在in子句中的选择不应该是*而是featureID。
delete from featured
where featuredID IN(
select top(@removeAmnt) featured.featuredid from featured
order by featured.createdon as
)