• arnipetursson (1/15/2013)


    Be careful in using @ type temporary tables.

    The optimizer has no statistics on @ tables and assumes it has ONE row.

    Even if you put a primary key on it, the PK only acts as a constraint.

    If you have more than a handful of rows in the @ table, you may have performance issues.

    You are better off using # temp table instead, if the table will contain more than a handful of rows.

    Just to clarify, handful is approximately 1,000 rows. Depends on the data-sizes involved. Below that size, SQL Server will often ignore indexes, etc., anyway.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon