当我得到异常Incorrect syntax near the keyword 'TOP'
时,我将它用作LIMIT。
也许我可以在没有问题的情况下省略它,但如果我不能在哪里放顶?
INSERT INTO [user_data] (...) SELECT
...
@14 WHERE not exists (SELECT * FROM [user_data] WHERE [email] = @15 OR
[name] = @16 OR
[unconfirmed_email] = @17 TOP 1);
答案 0 :(得分:5)
TOP
在SQL Server中SELECT
之后,而不是LIMIT
在其他DBMS中的位置。
SELECT TOP 1 <fields> FROM ...
所以你的查询将成为:
INSERT INTO [user_data] (...) SELECT
...
@14 WHERE not exists (SELECT TOP 1 * FROM [user_data] WHERE [email] = @15 OR
[name] = @16 OR
[unconfirmed_email] = @17);