Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Importing from a improperly formatted excel file


Importing from a improperly formatted excel file

Author
Message
Chrissy321
Chrissy321
Say Hey Kid
Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)

Group: General Forum Members
Points: 668 Visits: 4575
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...?
pietlinden
pietlinden
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2178 Visits: 12518
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.
Chrissy321
Chrissy321
Say Hey Kid
Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)Say Hey Kid (668 reputation)

Group: General Forum Members
Points: 668 Visits: 4575
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.
pietlinden
pietlinden
SSCrazy
SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)SSCrazy (2.2K reputation)

Group: General Forum Members
Points: 2178 Visits: 12518
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.)
mickyT
mickyT
Ten Centuries
Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)Ten Centuries (1.3K reputation)

Group: General Forum Members
Points: 1253 Visits: 3309
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.
richardmgreen1
richardmgreen1
Right there with Babe
Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)Right there with Babe (786 reputation)

Group: General Forum Members
Points: 786 Visits: 894
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.
Mr. Kapsicum
Mr. Kapsicum
Right there with Babe
Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)Right there with Babe (748 reputation)

Group: General Forum Members
Points: 748 Visits: 973
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search