• The code shows a clear cut example of why columns in a query should always be qualified. I.e., ALWAYS use aliases!

    I got burnt badly with a DELETE statement in a trigger that was using an unqualified reference to the "DELETED" table with the end result being that more rows than what was intended was being deleted.

    Using an alias on the table and then qualifing the column will shake out any coding errors, typos, etc. during the parsing phase of the query execution.

    Example delete trigger:

    DELETE FROM Foo

    WHERE FooBar IN (SELECT d.FooBar FROM deleted d)


    [font="Arial Narrow"](PHB) I think we should build an SQL database. (Dilbert) What color do you want that database? (PHB) I think mauve has the most RAM.[/font]