• Grant Fritchey (10/8/2008)


    If you're using table variables that are more than a few rows in size, switch them to temp tables. Except for a primary key, table variables have not statistics where as temp tables do. This means that they are treated as one row tables for all execution plans, which can lead to some seriously bad performance.

    Also, if joining the table variable to other tables - especially large tables - switch to temp table, EVEN IF the number of rows in the table variable is small. The lack of stats in the table variable can lead to a suboptimal plan for the join query.

    __________________________________________________________________________________
    SQL Server 2016 Columnstore Index Enhancements - System Views for Disk-Based Tables[/url]
    Persisting SQL Server Index-Usage Statistics with MERGE[/url]
    Turbocharge Your Database Maintenance With Service Broker: Part 2[/url]