• The code's not really ready to be used in dev or QA either.

    NO reason to search the same table multiple times, esp. not once per column.

    Instead, should do a single access to each table for all relevant columns in one query.

    SQL DBA,SQL Server MVP(07, 08, 09) A socialist is someone who will give you the shirt off *someone else's* back.