Hi,
Openrowset is one of the way to import data from excel into the sql server 2005: Below is the query usually used for this
insert into MyTable
select from OpenRowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\Report.xls',
'select * from ReportData'
)
However, i need to send the filename to OPENROWSET via a variable. This variable will be an input parameter to the stored procedure having the above statement.
CREATE PROCEDURE MyProc
( Declare @FileName nvarchar(50)
)
AS
BEGIN
insert into MyTable
select from OpenRowset(
'Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=@FileName',
'select * from ReportData'
)
Can it be done? I tried doing this but couldnt achieve this!!
Kindly advice
Regards,
Naveen