在注释DELETE语句并尝试使用SELECT语句时,代码运行正常。 请帮忙
DELETE FROM
--select * from
Site as s
join
(select SiteID,Code, Name, Dense_rank() over (partition by Code order by SiteID ) as Rank from Site
) as t
on s.SiteID = t.SiteID
WHERE t.Rank != 1
获取以下错误消息
Msg 156, Level 15, State 1, Line 5
Incorrect syntax near the keyword 'as'.
Msg 156, Level 15, State 1, Line 8
Incorrect syntax near the keyword 'as'.
答案 0 :(得分:5)
您不能为delete
表添加别名,但delete
可以引用别名。而不是:
delete from Site as s
...
尝试:
delete from s
from Site as s
...