Is any error in my query?
Hello friends
This is my store procedure
create procedure sp_excelforgeneralholidays(@filname nvarchar(max))
as
declare @datavar varchar(200)
declare @sql varchar(500)
set @datavar = 'Excel 8.0;DATABASE=' + @filname
set nocount on
begin
--create table #temptable (Date date ,Day varchar(30),Reason varchar(100))
set @sql = INSERT INTO Genaral_holydays_details(Date,Day,Reason) SELECT Date,Day,Reason FROM OPENROWSET('Microsoft.jet.OLEDB.4.0','+@datavar +;HDR=YES','SELECT Data,Day,Reason FROM [Sheet1$]')
exec (@sql)
end
and the excution part is
exec sp_excelforgeneralholidays'D:\baskaran\baskarbook1'
The error is incorrect syntax near INSERT