Puting data into temporary table by executing procedure.

  • Dear All,

    I have "Execute " right for a procedure in another database.

    I dont have any other control on that preocedure but to execute.

    Depends on the value I pass, this procedure returns different number of feilds and records.

    For example - execute Proc_AMS_NAV_GetMasterData_NEW 'BRANCH'.

    Now I want to put this records into a temporary table (for filter purpose.).

    I tried with the following command but it's not working..

    select * into #tmp

    from

    (

    execute Proc_AMS_NAV_GetMasterData_NEW 'BRANCH'

    ) A

    Can any one help me pls...It's urgent..

    Thanks in advance..

    Santhu.

  • To do what you are trying, you first have to define (create) the temporary table with the columns defined with the appropriate data types that will be returned, then you can use the following:

    insert into #TempTable

    exec dbo.YourStoredProc paramvalue;

  • First create temp. table and then use the following way:

    insert into #temptable

    exec sp_name;

    🙂

  • That's the problem..

    We cant define the table straucture like that..It is depended on the parameter we pass.Number of fields and it's data types will vary as per the parameter passed.

    Is there any other way out..?

  • nairsanthu1977 (11/18/2008)


    That's the problem..

    We cant define the table straucture like that..It is depended on the parameter we pass.Number of fields and it's data types will vary as per the parameter passed.

    Is there any other way out..?

    explain more detail about your exact requirement.

  • Exec GetNav_Data @TableName = 'SERVICETAX'

    Exec GetNav_Data @TableName = 'TDSNATUREOFDEDN'

    Exec GetNav_Data @TableName = 'VendorDetails'

    Exec GetNav_Data @TableName = 'PaymentMethodCDD'

    All the above commands will return me different type of records...(diff columns and values). Hence am not able to define define the table in advance.

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

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