2

注释 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'.
4

1 回答 1

6

您不能为delete表设置别名,但delete可以引用别名。而不是这个:

delete from Site as s
...

尝试:

delete from s
from Site as s
...
于 2012-06-23T09:22:58.627 回答