"Select * from @var" possible?

  • I'm not suggesting you use it as it is a big overhead.

    It can be used as a method of calling an SP and creating a temp table from the results without knowing what the table is going to look like beforehand (I found out about this because someone on another forum said it wasn't possible).

    I wonder why people want to do this as there is then not a lot you can do with the table - except I guess generate dynamic sql to manipulate it.

    I always think that if you are trying to do this then you should probably rethink the design.

    To use it create a linked server link to your own server then you can access it from openquery and create a temp table from it.

    select * into #a from openquery(mylinkedserver,'select * from mydb.dbo.sysobjects')

    or for an SP

    select * into #a from openquery(mylinkedserver,'exec sp_who')

    You can do a similar thing with openrowset (I think) if you don't want to cerate the linked server.

    Edited by - nigelrivett on 11/22/2001 08:07:54 AM


    Cursors never.
    DTS - only when needed and never to control.

Viewing post 16 (of 15 total)

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