Tuesday, September 30, 2008

SQL 2005: Delete Records Using Another Table

DELETE tobeupdated_table FROM tobeupdated_table  a
WHERE a.tableID = @ID_in
       AND a.otherTableID IN 
           ( SELECT otherTableID  FROM otherTable b
                    WHERE b.someField = @someValue_in
           );

No comments: