• I think SQL parses things a batch at a time. All your code is in the same batch, and the table is created in that batch. That might be why SQL doesn't recognize that the table exists in the later SELECT statement(s).

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