Hi friends
this is my store procedure for getting external excel file and save into sql database.
create procedure sp_excelforgeneralholidays(@filname nvarchar(max))
as
set nocount on
begin
select * from OPENROWSET('Microsoft.jet.OLEDB.4.0','Excel 8.0;DATABASE=' + @filname + ', Select Date,Day,Reason from [sheet1$])'
end
When i Run this error is near syntax error + . but i dont know how to solve this problem please help me
Loading

Javeed M ShaikhRank #839 · 2.7K reputationPosted Aug 22, 2012, 12:26 PM EDT
try this.
create procedure sp_excelforgeneralholidays(@filname nvarchar(max))
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 22, 2012, 12:35 PM EDT
replace select statement with the following:
exec('select * from OPENROWSET(''Microsoft.jet.OLEDB.4.0'',''Excel 8.0;Database='+@filename+',select date, day,reason from [sheet1$])')
baskaran chellasamy112 reputationPosted Aug 22, 2012, 1:15 PM EDT
Javeed M ShaikhRank #839 · 2.7K reputationPosted Aug 22, 2012, 1:19 PM EDT
baskaran chellasamy112 reputationPosted Aug 22, 2012, 1:24 PM EDT
Akkiraju IvaturiRank #473 · 5.3K reputationPosted Aug 22, 2012, 4:25 PM EDT
http://www.kodyaz.com/articles/enable-Ad-Hoc-Distributed-Queries.aspx