Delete from multiple tables using temp table variable
p is a cryptic table alias and that != is not ANSI compliant, you should try and use &lt;&gt; instead. Also, the select * from is inefficient because it has to go back to the information schema and look up every column, you should try and only select the columns you really need.