Explore Courses Blog Tutorials Interview Questions
0 votes
in SQL by (20.3k points)

In SQL Server Compact Edition in Visual Studio 2010 (maybe SQL Server and SQL in general, I don't know), this command works:

DELETE FROM foods WHERE (name IN ('chickens', 'rabbits'))

but this command produces an error of Error near identifier f. Expecting OUTPUT.

DELETE FROM foods f WHERE ( IN ('chickens', 'rabbits'))

1 Answer

0 votes
by (40.7k points)
edited by

To alias the table name you can use the below code:

DELETE f FROM dbo.foods AS f WHERE IN (...);

According to IIRC, DELETE statement is not strictly ANSI. But, for other query forms such as correlation aliasing is necessary. 

Browse Categories