temp table in view

  • Hello All,

    Is it a good practice to use a temp tables in a view?

    How do we handle temp tables in views?

    Please explain in detail.

    Thank you,

    Sra1

  • sravanb (10/28/2010)


    Hello All,

    Is it a good practice to use a temp tables in a view?

    How do we handle temp tables in views?

    Please explain in detail.

    Thank you,

    Sra1

    Others will provide a far more sophisticated answer, here's the simple one: if a view is a persisted or "permanentised" query, then what's something transient and undefined gotta do with it?


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • Is it good practice to use temp tables in a view...

    Quick Answer: You can't. Views are single statement activities.

    You can use cte's to help keep code readable. You can subselect to the end of the earth. But you can't do multi-part statements.

    If the question is regarding a global temp table (##tmp)... don't do it. More headaches then it'll ever be worth to you.


    - Craig Farrell

    Never stop learning, even if it hurts. Ego bruises are practically mandatory as you learn unless you've never risked enough to make a mistake.

    For better assistance in answering your questions[/url] | Forum Netiquette
    For index/tuning help, follow these directions.[/url] |Tally Tables[/url]

    Twitter: @AnyWayDBA

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply