Solved

excel & SQL

Posted on 2016-08-23
8
64 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 32

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 32

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
 

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
 
LVL 32

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
Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

 

Author Comment

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
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…

895 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

11 Experts available now in Live!

Get 1:1 Help Now