How to select from a temporary table using a dynamic query

  • How do I sleect from a populated temporary table using a dynamic query

    declare @Tmp table (.....)

    SET @SQLString =N'select * from @Tmp'

    EXECUTE sp_executesql @SQLString

    I am getting : Must declare the table variable "@Tmp".

  • markcrosbie (3/21/2013)


    How do I sleect from a populated temporary table using a dynamic query

    declare @Tmp table (.....)

    SET @SQLString =N'select * from @Tmp'

    EXECUTE sp_executesql @SQLString

    I am getting : Must declare the table variable "@Tmp".

    The table @Tmp is a table variable and it can't be used this way. You can create a temporary table (#Tmp) and what you are attenpting will work.

  • Aaah...thank you so much

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

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