Table variables

  • Well, this was an easy one!

    You can use table variables in some type of functions, but not in all. You can't use(declare) a table variable in an inline table valued function, but you can pass a user defined table parameter.

    In an inline table valued function, you can only have one single select statement.

    /Håkan Winther
    MCITP:Database Developer 2008
    MCTS: SQL Server 2008, Implementation and Maintenance
    MCSE: Data Platform

  • thanks for the easy question.

  • Thanks for the semi-easy question. I say semi-easy because I was going to just jump all over it and be like "Yes! Of course you can!" and then the uncertainty hit me and I thought to myself..."This is QotD...so...what's the catch?" After a few moments of deep thought, I went with my gut and got it right.



    Everything is awesome!

  • Really, really easy one - thanks!

  • Thanks for a good (and not tricky) question.

  • Thanks for the easy one! Should have been "can temp tables" be used in UDFs - that may have fooled a few :hehe:

    ______________________________________________________________________________Never argue with an idiot; Theyll drag you down to their level and beat you with experience

  • L' Eomot Inversé (12/18/2012)


    Nice easy one today.

    Perhaps it would have been a good idea to provide the appropriate BoL reference: CREATE FUNCTION (Transact-SQL) which contains the statement

    In multistatement table-valued functions, @return_variable is a TABLE variable, used to store and accumulate the rows that should be returned as the value of the function

    and that answers the question rather clearly - if some functions have to use a table variable, then certainly functions can use table variables.

    +1

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • Excellent one-point question. 21% wrong answers = no such thing as a too-easy QotD.

  • Nice Question and Easy

  • we can use table variable in UDF's. But performance issues will raise.....:w00t:

    Manik
    You cannot get to the top by sitting on your bottom.

  • used it today !

Viewing 11 posts - 16 through 25 (of 25 total)

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