July 16, 2009 at 7:38 am
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]
July 16, 2009 at 8:29 am
If you set up a linked server to the external file, that should work.
July 27, 2009 at 11:19 am
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
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply
This website stores cookies on your computer.
These cookies are used to improve your website experience and provide more personalized services to you, both on this website and through other media.
To find out more about the cookies we use, see our Privacy Policy