Create temp table with dynamic columns

  • Hi guy,

    I have this situation:

    declare @TEMP_DB table(column1, column2 column3 )

    insert into @TEMP_DB exec myStoredProcedure 'value1','value2'

    the question is easy:

    myStoredProcedure return one o more columns, according as the values of the input.

    There isn't to know first how many columns.

    I cannot use in different ways the storedprocedure, only this.

    I should like creating the TEMP_DB in dinamyc mode.

    Therefore I can use the result for other scope.

    However I don't know if is possibile:

    1) Create the temp table with n columns, or without columns.

    2) or Use some system stored for the result of my storedprocedure.

    You can help me?

    thank!!!!!

  • why not use a function, instead of a stored procedure, and have the function return a @Table?

    then you'd have what you are after...

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • I cannot use Fuction

    beacuse in my storedprocedure I use "executesql" 🙁

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

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