Solved

excel & SQL

Posted on 2016-08-23
8
79 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 33

Accepted Solution

by:
Rob Henson earned 334 total points
ID: 41767137
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 33

Assisted Solution

by:Rob Henson
Rob Henson earned 334 total points
ID: 41767151
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
 
LVL 1

Author Comment

by:ITsolutionWizard
ID: 41767318
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
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 33

Expert Comment

by:Rob Henson
ID: 41767336
It isn't code, Text to Columns is a standard feature. Follow the steps in my first post.
0
 
LVL 1

Author Comment

by:ITsolutionWizard
ID: 41767498
I mean the SQL
0
 
LVL 33

Expert Comment

by:Rob Henson
ID: 41767549
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
ID: 41767629
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 14

Expert Comment

by:frankhelk
ID: 41815697
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

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
This article describes a serious pitfall that can happen when deleting shapes using VBA.
Graphs within dashboards are meant to be dynamic, representing data from a period of time that will change each time the dashboard is updated with new data. Rather than update each graph to point to a different set within a static set of data, t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

705 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