• AJ-636201 (2/25/2011)


    Hi,

    I am a bit confused about the table variables. As transaction does not affect the table variable operations. So is there any way to force table variable to be part of transaction or in such situations we'll have to use temp tables only?

    Also when we submit a query having a table variable then the query optimizer always assumes only single row and the statistics are not generated for the table variable so I am curious that why table variables are better option over temp tables (not always)?

    Regards,

    AJ:unsure:

    I was thinking that I had read a good article about this topic not long ago. 🙂

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/