Is it possible to use select * into #tmptbl from EXEC SP?

  • Hi,

    Is there anybody can help me take a look?

    I want to create one temp tble by using the query like select * into #tmptbl from EXEC SP... Becasue the temp table's column only depend on the result of "EXEC SP", we can't create temp table like "insert ino () EXEC SP", do you have any suggestion for this case? really appreciated if you can share something with me. Thanks a lot.

    Thanks

    Lindsay

  • The number of column returned by the EXEC statement is dynamic ?? I mean, for each execution of the SP, will it return inconsistent number of COLUMNS ?

  • look at openquery() it might work for what you want to do.

    The probability of survival is inversely proportional to the angle of arrival.

  • lindsaywang (3/15/2011)


    Hi,

    Is there anybody can help me take a look?

    I want to create one temp tble by using the query like select * into #tmptbl from EXEC SP... Becasue the temp table's column only depend on the result of "EXEC SP", we can't create temp table like "insert ino () EXEC SP", do you have any suggestion for this case? really appreciated if you can share something with me. Thanks a lot.

    Thanks

    Lindsay

    If you can process all the code in the sub proc, then you can do select into in the sub proc. Maybe then you can call an extra sub sub proc conditionally to finish the processing.

  • Thank you ALL:)

    Yes, the EXEC will return inconsistent number of COLUMNS, because it is one SP which can help us do something..... I tried the OpenQuery, seems that it works for me. Thanks again.

    Thanks

    Lindsay

Viewing 5 posts - 1 through 4 (of 4 total)

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