August 17, 2017 at 7:47 am
I feel like I'm missing something incredibly simple here. I'm trying to import data from a file we received from another company. The worksheet I want to import from is named is named "KRS_144D Monthly Cumulative Cla". The data in the Worksheet is located in the Range B9:AD. I'm using the SQL Server Import and Export Wizard right now, rather than SSDT, but did the usual steps:
SELECT *
FROM [KRS_144D Monthly Cumulative Cla$B9:AD];
Upon clicking Parse/Next > I receive the error:
The statement could not be parsed.
------------------------------
ADDITIONAL INFORMATION:
The Microsoft Jet database engine could not find the object 'KRS_144D Monthly Cumulative Cla$B9:AD'. Make sure the object exists and that you spell its name and the path name correctly. (Microsoft JET Database Engine)
If I remove the B9:AD portion of the statement, the query passes fine.it doesn't like having the cell reference, for some reason. Not had this problem with any other sheet. Anyone got any ideas if I'm doing something "stupid"? I've tried the following permutations, but none seem to work with the cell reference:
[KRS_144D Monthly Cumulative Cla$B9:AD]
['KRS_144D Monthly Cumulative Cla$'B9:AD]
['KRS_144D Monthly Cumulative Cla$B9:AD']
['KRS_144D Monthly Cumulative Cla'$B9:AD]
I'd hazard a guess it's probably the one or a combination of the Max length Worksheet name, having spaces, and that the file is xls not xlsx (so uses the JET engine, rather than ACE). Anyone got any ideas on a work around?
Thanks all.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
August 17, 2017 at 8:11 am
Don't you need to add a ending cell number as you cant go up to cell AD1 as you start in cell B9 in Excel, so you need to define the whole selection as a square?
SELECT * FROM [KRS_144D Monthly Cumulative Cla$B9:AD32456];
Or could you doSELECT * FROM [KRS_144D Monthly Cumulative Cla$B:AD];
then delete the first 8 blank rows from the table?
August 17, 2017 at 8:23 am
anthony.green - Thursday, August 17, 2017 8:11 AMDon't you need to add a ending cell number as you cant go up to cell AD1 as you start in cell B9 in Excel, so you need to define the whole selection as a square?
SELECT * FROM [KRS_144D Monthly Cumulative Cla$B9:AD32456];
Or could you do
SELECT * FROM [KRS_144D Monthly Cumulative Cla$B:AD];
then delete the first 8 blank rows from the table?
With xlsx you don't need to declare the end of the file, no (as you may not know where the end of the file is). When you use it like I did, for example, ACE would load up to the lowest user editted row. I wasn't sure, however, if JET reacted in the same way. Gave it a go, but the same error returned.
Using B:AD doesn't work either, however, considering that the file contains numerics and dates and Excel has a habit of importing non-string values in odd manner when importing them as a string, that isn't a solution I'd want to pursue anyway. For example a sheet I was working with earlier imported the date 2013-04-29 as the string "41393"; that's 1900-01-01 + (41393 - 2) days (0 is 1899-12-30 in Excel...?).
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
August 17, 2017 at 8:33 am
So, I felt like trying something "stupid". The file is definitely an xls (1997-2003) file, however, I set the import wizard to xlsx (2007-2010). Worked straight away.
I assume that the problem is with JET, and that the ACE drivers were happy to deal with the declared Cell Reference. in teh Worksheet name.
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
August 22, 2017 at 8:39 pm
Thom A - Thursday, August 17, 2017 8:33 AMSo, I felt like trying something "stupid". The file is definitely an xls (1997-2003) file, however, I set the import wizard to xlsx (2007-2010). Worked straight away.I assume that the problem is with JET, and that the ACE drivers were happy to deal with the declared Cell Reference. in teh Worksheet name.
I'll also tell you that, with the ACE drivers and so long as there's nothing in the columns to the left or the rows above the starting cell, you don't need to tell it what the starting cell is. It figures it out auto-magically.
I guess I also ask, why in the world are you using that awful import wizard? And how often do you need to do this?
--Jeff Moden
Change is inevitable... Change for the better is not.
August 23, 2017 at 1:19 am
Jeff Moden - Tuesday, August 22, 2017 8:39 PMI'll also tell you that, with the ACE drivers and so long as there's nothing in the columns to the left or the rows above the starting cell, you don't need to tell it what the starting cell is. It figures it out auto-magically.I guess I also ask, why in the world are you using that awful import wizard? And how often do you need to do this?
There was a value in cell A1, so hence the declared range. Even so, I don't really trust the ACE drivers half the time, so generally I prefer to tell it where the data I want is, even if it thinks it knows better (or is right).
I only, as a rule of thumb, use the importer when I first receive file for the first time. I might get a few new types a files a year. I'll run it through the import wizard quickly to see how it comes out and how well the data actually matches ours. After a trial, then I go to SSIS and do it all properly for automation, often storing the data in a staging table, and then going on to put it where it needs to go to properly (as, like we all know, ACE has its quirks).
Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk
August 23, 2017 at 2:17 am
I hate trying to import Excel into SQL Server, for the reasons already stated, this is yet another area where MS does it so badly.
ACE really needs an option like IMEX to tell ACE to retrieve data as text with no formatting or conversion.
Fortunately at the moment my spreadsheets have standard layouts and no mixed data columns.
I have an old VB6 app that I wrote that extracted the first sheet as a text file with no formatting or conversion and then I would import the text file.
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply