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
151k
Please solve this error
Aug 23 2012 5:29 AM
Hi friends
This is my stored procedure
alter procedure sp_excelforgeneralholidays(@filname nvarchar(max))
as
declare @datavar varchar(200)
declare @sql varchar(500)
set @datavar = 'Excel 8.0;DATASOURCE=' + @filname
set nocount on
begin
--create table #temptable (Date date ,Day varchar(30),Reason varchar(100))
set @sql = SELECT * FROM OPENDATASOURCE('Microsoft.jet.OLEDB.4.0','+@datavar +;HDR=YES','SELECT Data,Day,Reason FROM [Sheet1$]')
exec (@sql)
end
In the parameter of storedprocedure I just pass filename with their location. But this query is not run correctly.please rectify the error if i made the error.
and the error when i run this storeprocedure
Msg 156, Level 15, State 1, Procedure sp_excelforgeneralholidays, Line 10
Incorrect syntax near the keyword 'SELECT'.
Msg 102, Level 15, State 1, Procedure sp_excelforgeneralholidays, Line 10
Incorrect syntax near ','.
Reply
Answers (
1
)
invalid object name or table name in sql server 2008?
Add World Map in SQL Server 2012