Output from Stored Procedure

  • Hi All,

    EXEC sp_addlinkedserver TEXT_LS, 'Jet 4.0', 'Microsoft.Jet.OLEDB.4.0', 'C:\files\', NULL, 'Text'

    GO

    EXEC sp_addlinkedsrvlogin TEXT_LS, false, NULL, NULL, NULL

    exec sp_tables_ex TEXT_LS

    From the above script is it possible to get the output to the table. for ex:

    select * into Test exec sp_tables_ex TEXT_LS

    However, I am getting output when I execute "exec sp_tables_ex TEXT_LS" .

    Thanks in advance for any input in this.

    Regards,

    Mohanraj Jayaraman

  • Hi,

    If I've read that correctly you can insert the results in to a table. You will need to create the table to hold the expected results first but you can then use:

    INSERT INTO test

    EXEC sp_tables_ex TEXT_LS

    HTH,



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

  • Hi

    Thanks for you reply its works for me.

    At the time of interview they asked me this question but I dont have answer for this (select * into ..... )

    Do you know why select * into will not work when Insert into works.

    Regards,

    Mohanraj Jayaraman

  • Without going in to specifics (as I don't know why it happens this way), the data will be returned from the procedure by a SELECT statement. Using SELECT * INTO x EXEC would basically be trying to SELECT * INTO x FROM SELECT ..... which is syntactially bad.

    INSERT INTO x EXEC would be INSERT INTO x SELECT... which is the correct way in a single statement.



    Ade

    A Freudian Slip is when you say one thing and mean your mother.
    For detail-enriched answers, ask detail-enriched questions...[/url]

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

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