Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 SQL error

Author  Topic 

tanu
Yak Posting Veteran

57 Posts

Posted - 2008-04-21 : 15:14:54
I could not figure out what is wrong here.
Declare @datasource varchar(70),
@filenameImport varchar(150)
SELECT * INTO Test FROM OPENDATASOURCE('Microsoft.Jet.OLEDB.4.0',
'Data Source ='+ @filenameImport + ';Extended Properties=Excel 8.0')...[Sheet1$]

Msg 102, Level 15, State 1, Line 4
Incorrect syntax near '+'.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-21 : 15:16:41
You'll need to use dynamic SQL for that.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-04-22 : 05:27:45
Refer this and find the example
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -