我的语法有什么问题?

时间:2012-02-24 08:44:37

标签: sql-server-2008 syntax

WHILE @@ROWCOUNT <> 0
BEGIN
     CHECKPOINT;
    DELETE TOP (300000)
      FROM [dbo].[Event] AS E
     INNER JOIN #tempEvents AS TE
        ON E.[EventID] = TE.[EventID]
END

首先,我得到: Incorrect syntax near the keyword 'AS'.

所以,我删除了这个并用带有完整表名的别名替换,这给了我: Incorrect syntax near the keyword 'INNER'.

我发现了question这是我发现INNER JOIN的地方,但是SQL Server没有正确解析它。有什么想法吗?

1 个答案:

答案 0 :(得分:3)

试试这个:

WHILE @@ROWCOUNT <> 0
BEGIN
     CHECKPOINT;
    DELETE TOP (300000) E
      FROM [dbo].[Event] AS E
     INNER JOIN #tempEvents AS TE
        ON E.[EventID] = TE.[EventID]
END

你错过了top语句后的tablename / alias。