Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Importing from a improperly formatted excel file Expand / Collapse
Author
Message
Posted Wednesday, September 25, 2013 1:39 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 4:10 PM
Points: 646, Visits: 3,782
Any guidance would be appreciated. Despite my protestations I have been tasked to import from an excel file. The file is not what I would call a proper data file. The data will start in cell D10 and end in cell Kx where x is the number of data rows in the file.

What are my options here. My first thought would be to use SSIS and dump say cell A1 through K10000 ( assuming I would never have more than 10000 rows) into a staging table and parse the data out.

Anyone been down this road...?
Post #1498571
Posted Wednesday, September 25, 2013 3:34 PM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 12:45 PM
Points: 703, Visits: 4,490
One option might be to use Access (shudder, I know) to create a linked table that only links to the data you want and then export that back to Excel to a new file.

Post #1498607
Posted Wednesday, September 25, 2013 3:43 PM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Today @ 4:10 PM
Points: 646, Visits: 3,782
pietlinden (9/25/2013)
One option might be to use Access (shudder, I know) to create a linked table that only links to the data you want and then export that back to Excel to a new file.


So access can create linked table to a portion of a spreadsheet? And then I could create a linked server from SQL Server to the access table? Never would have thought of it. I would be venturing into Rube Goldberg machine territory.

Ok I'll add this to the list of possible solutions.
Post #1498613
Posted Wednesday, September 25, 2013 5:19 PM
Say Hey Kid

Say Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey KidSay Hey Kid

Group: General Forum Members
Last Login: Today @ 12:45 PM
Points: 703, Visits: 4,490
See the second example in this article:
http://access.mvps.org/access/general/gen0008.htm

then once the data is in Access, you can do whatever... (Probably export back out... and go through SSIS as planned.)
Post #1498629
Posted Wednesday, September 25, 2013 9:10 PM
SSC Eights!

SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!SSC Eights!

Group: General Forum Members
Last Login: Today @ 5:20 AM
Points: 950, Visits: 2,876
Another option (and another shudder ) if you don't mind waiting and have a sandbox type database it to:
Creating a staging table for the data.
Selecting the 'Edit top 200 rows' option in the SMSS drop down menu.
Copy the data in Excel and paste into the edit grid.

Beware this is slow and I only do it for ad hoc data where I have no more than a couple of thousand or so rows. It does generally get the data in there with minimal fuss.
Post #1498651
Posted Friday, September 27, 2013 4:41 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Today @ 4:38 AM
Points: 282, Visits: 356
I've been there and done something similar to what you need to do.
I used Access and created a linked table to the spreadsheet and another linked table to the staging table on SQL.
The data was then dumped into the staging table before being processed and put into the production tables.
Doing it this way, you can add things like "is not null" to ignore the empty rows at the start of the file at either end of import.
It's not the fastest thing in the world but it worked for me.
Post #1499305
Posted Friday, September 27, 2013 4:51 AM
SSC-Addicted

SSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-AddictedSSC-Addicted

Group: General Forum Members
Last Login: Tuesday, July 8, 2014 12:25 AM
Points: 445, Visits: 565
well i guess,,,,,, SSIS package (Data Flow task ) may help you in this.

IF,Number of columns in your excel files are going to be fix.....Then u can pump "N" number of rows into your Database tables.
Post #1499307
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse