I want to delete rows from a SQL Server 2000/2005 table variable based on the presence of other rows in the same table (delete all 0 count rows if a non-0 count row exists with
Try this, it ought to work (the first FROM is optional):
DELETE [FROM] @O
FROM @O o1
where ACount = 0
and exists (select Month from @O o2
where o1.Month = o2.Month and o2.ACount > 0)
The rationale is: DELETE, as explained here, expects a non-aliased table first, an optional FROM can precede it. After that you do can put an alias on a table in the second FROM, if you need to do a JOIN, subquery, etc.