TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
baskaran chellasamy
NA
114
150.2k
Is any error in my query?
Aug 23 2012 3:04 AM
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
Reply
Answers (
3
)
Error in import excel to sql query
invalid object name or table name in sql server 2008?