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'))
To alias the table you’d have to say:
…though I fail to see the point of aliasing for this specific statement, especially since (at least IIRC) this no longer conforms to strict ANSI, may cause unnecessary hurdles when writing for multiple platforms, and it introduces complexity and confusion for new users learning the basics of vanilla DML.
This will do and doesn’t require an alias:
But yes, as comments suggest, it may be necessary for other query forms (e.g. any DML combined with correlation, joins,
EXISTS, etc). In SQL Server you can do this using, for example:Just keep in mind this query may have to be constructed differently on {not SQL Server}.