Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
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 (f.name 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 f.name IN (...);

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

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...