Solved

excel & SQL

Posted on 2016-08-23
8
57 Views
Last Modified: 2016-09-26
Please open attached file in excel.

I have over 5000 rows of the similar format in excel. and have two things need help.

1. How can I extract the number like first row 1429156 into different column
2. How can i extract the last name and first name smith (lastname), jayle (firstname) into different column.

After then, I will take the excelsheet and import into the table.
(This is something I want to learn if you can show me :-)). I know how to import data into the table.
1. How can I extract the number like first row 1429156 in SQL
2. How can i extract the last name and first name smith (lastname), jayle (firstname) in SQL
sample.xlsx
0
Comment
Question by:ITsolutionWizard
8 Comments
 
LVL 31

Accepted Solution

by:
Rob Henson earned 334 total points
Comment Utility
You can split the data into separate columns using the Text to Columns wizard.

Select the data in column A and then from the Data ribbon select "Text to Columns".

Step 1 - Select Delimited Radio button, click Next
Step 2 - Check boxes against Space and Other, in box next to Other enter a comma, click Next
Step 3 - If you want the contents of column A overwritten leave Destination as $A$1 otherwise change to $B$1. To ensure the dates are populated correctly, select the header of each of the date columns, choose the Date radio button and use the dropdown next to it to specify the format. This is the format of the source data as opposed to how the dates should end up.
Click Finish.

As for doing it in SQL - sorry, beyond me. I guess each of the sections of the text come from different fields of the table so should be able to extract separately.

Thanks
Rob H
0
 
LVL 31

Assisted Solution

by:Rob Henson
Rob Henson earned 334 total points
Comment Utility
There are potential issues with Text to Column if a line does not fit the same convention as other lines.

For example in your sample, row 11 does not have a first name; resulting split data ends up out of alignment.

If your names could have second names or initials that would also mess it up eg if "TURNER, SAMF" was "TURNER, SAM F" (note space between SAM & F) this would also give misalignment.

Thanks
Rob
0
 

Author Comment

by:ITsolutionWizard
Comment Utility
please show me the codes. if I do not expect the codes will work perfectly to match up.
I will review it and correct manually.
0
 
LVL 31

Expert Comment

by:Rob Henson
Comment Utility
It isn't code, Text to Columns is a standard feature. Follow the steps in my first post.
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:ITsolutionWizard
Comment Utility
I mean the SQL
0
 
LVL 31

Expert Comment

by:Rob Henson
Comment Utility
Sorry, don't know SQL. My earlier comment was merely a guess based on VERY limited knowledge.
0
 
LVL 27

Assisted Solution

by:Glenn Ray
Glenn Ray earned 166 total points
Comment Utility
Your source data appears to have fixed width values (12, 8,11,11 characters each).  Using Text-To-Columns in Excel would easily split up the data.  As Rob noted, however, your sample data set is truncating the names in such a way that all or part of the first names are missing.  

Whatever process is generating this data would need to be revised first so that the full names are listed (perhaps expand the output of the full name field to say 30-35 characters rather than 12).  Then you can easily parse out the contents.

I've attached a modified version of your workbook that shows how the first and last names - such as they are - can be extracted from the parsed data.  The "Original" sheet shows your example, plus screenshots of the Text-To-Columns dialog boxes needed to prepare the data.  The "Sheet1" sheet shows the parsed data plus two new columns with formulas for showing the first and last names.

First Name:
E2: =IFERROR(MID(A2,FIND(",",A2)+2,20),"")

Last Name
F2: =IFERROR(LEFT(A2,FIND(",",A2)-1),A2)

Regards,
-Glenn
EE-sample.xlsx
0
 
LVL 13

Expert Comment

by:frankhelk
Comment Utility
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Rob Henson (https:#a41767137)
-- Rob Henson (https:#a41767151)
-- Glenn Ray (https:#a41767629)


If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

frankhelk
Experts-Exchange Cleanup Volunteer
0

Featured Post

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
This Micro Tutorial will demonstrate on a Mac how to change the sort order for chart legend values and decrpyt the intimidating chart menu.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now