Is it possible to pass parameters to a SP from text/XLS file

  • Hi All,

    I have written a stored procedure which works well and gives the desired output. I am just wondering if I can read parameters from a text file in this SP. I need this because I want end users not to make any changes in the SP and pass the desired parameters.

    A small sample code to make myself more clear.

    [Code]

    create procedure dbo.spTest_SP

    AS

    BEGIN

    Select col1,col2

    from test_table

    Where Col1 in ('parameter1,'parameter2',---- Read all the parameters one by one from the text file here----)

    End

    [/Code]

    -- Ravinder Pal

  • If you set up a linked server to the external file, that should work.

  • Thank you for the reply. I tried but was not successful to make linked server to excel work. Though I used openrowset query with INSERT INTO and it solved my issue 🙂

    [Code]

    Insert into MyDb1.dbo.MyTable1

    SELECT * FROM OPENROWSET('Microsoft.Jet.OLEDB.4.0',

    'Excel 8.0;DATABASE=C:\List.xls', 'Select * from [Sheet1$]')

    [/code]

    and then I am using the imported data in the table to do the required calculations. Thanks for the help

    -- Ravinder Pal

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

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