The solution: https://stackoverflow.com/a/439768/857994 gives the following code:
DELETE TableA
FROM TableA a
INNER JOIN
TableB b on b.Bid = a.Bid
and [my filter condition]
My question is:
How come we don’t need an AS in the FROM to alias TableA to a here? Wouldn’t we need the AS in a select query like SELECT E.FirstName FROM Employee AS E;?
What’s the difference?
The “AS” keyword there is optional. You don’t need it in SELECT queries either. (Try it!)
Here’s some of the syntax of “FROM” from the MSDN:
As you can see, the
[ AS ]is in brackets, which means it’s optional. You never need to add it, though I suppose some may argue that it makes the query more readable. I disagree, but that’s a matter of personal preference (or your DBA’s personal preference).See http://msdn.microsoft.com/en-us/library/ms177634.aspx for more detail.