473,387 Members | 1,456 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Input Paramter as part of OPENDATASOURCE

I want to use an input parameter as my filename, but I get a synatax
error message. Howerve, when I hard code the filename the proc compiles
successfully.
Thanks for any help. I'm using SQL Server 2005
LTR_90,
LTI_ELIG_pct,
LTI_REC_pct,
LOW_SALARY,
HIGH_SALARY FROM OPENDATASOURCE("Microsoft.Jet.OLEDB.4.0",
"Data Source=C:\inetpub\wwwroot\ORC_Beta_Companies\"' + @infilename +
'"Extended Properties=Excel 8.0")...[summary_data$]
Syntax message:
Msg 102, Level 15, State 1, Procedure
importExcelSpreadSheetIntoeNavigator_DataORC, Line 244
Incorrect syntax near 'Microsoft.Jet.OLEDB.4.0'.

Jan 26 '07 #1
2 5210
Try puting the entire statement into a string variable and then
executing the string.

On Jan 26, 8:20 am, "paddy_nyr" <mpp...@yahoo.comwrote:
I want to use an input parameter as my filename, but I get a synatax
error message. Howerve, when I hard code the filename the proc compiles
successfully.

Thanks for any help. I'm using SQL Server 2005

LTR_90,
LTI_ELIG_pct,
LTI_REC_pct,
LOW_SALARY,
HIGH_SALARY FROM OPENDATASOURCE("Microsoft.Jet.OLEDB.4.0",
"Data Source=C:\inetpub\wwwroot\ORC_Beta_Companies\"' + @infilename +
'"Extended Properties=Excel 8.0")...[summary_data$]

Syntax message:

Msg 102, Level 15, State 1, Procedure
importExcelSpreadSheetIntoeNavigator_DataORC, Line 244
Incorrect syntax near 'Microsoft.Jet.OLEDB.4.0'.
Jan 26 '07 #2
paddy_nyr (mp****@yahoo.com) writes:
I want to use an input parameter as my filename, but I get a synatax
error message. Howerve, when I hard code the filename the proc compiles
successfully.
Dynamic SQL is the only way out. See
http://www.sommarskog.se/dynamic_sql.html#OPENQUERY
for an example with OPENQUERY that you can use as starter.

If you've never seen dynamic SQL before, I recommend that you read the
entire article, before you start using it all over town.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Jan 26 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Maxd out | last post by:
Hi all As a newbie to C++ just wondering if you can compare a user input e.g. the integer 2 to see if that integer is contained within a parameter list. If so how can it be done and can it be...
4
by: Jim Andersen | last post by:
Version 2000. How do I do something like the example SELECT * FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source="c:\Finance\account.xls";User ID=Admin;Password=;Extended...
1
by: David Horowitz | last post by:
Hi folks. I'm trying to connect to a Medisoft Advantage SQL db through SQL Server using OpenDataSource or OpenRowSet. I have general connections to the db working fine, but not with OpenDataSource...
1
by: lonestarprogramming | last post by:
I would like to create a stored procedure that imports an Excel file to a sql server table. I need to be able to pass the path to the spreadsheet to the stored procedure like so: CREATE...
0
by: korggrok | last post by:
I have a dialog window that pops up from the main app browser window. The window contains a form (name="savechanges") that includes an input (name="sql") that is a textarea input. The dialog...
8
by: John | last post by:
Hi Pasrt of HTML - <div class='button'><input type='image' src='/images/check1.jpg'></input></div> Part of CSS - ..button {background-image: url(/images/check1.jpg); background-repeat:
1
by: sayedul | last post by:
Hi, I can access data from xls file using OpenDataSource. But if the worksheet name starts with numeric character it gives error. Scripts are as follows: If the worksheet name is 'Sheet1' it...
0
by: htenay | last post by:
I need to be able to define an array in Java and pass it on to SQL stored procedure. I am new to store proc and found a lot of helpful tutorials on Google but found none that passes parameter of...
5
by: sepgiv | last post by:
I am using OPENDATASOURCE to read data from files when the file extension is txt ,retrieve is successful select * from OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.