• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 92
  • Last Modified:

excel & SQL

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
ITsolutionWizard
Asked:
ITsolutionWizard
3 Solutions
 
Rob HensonIT & Database AssistantCommented:
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
 
Rob HensonIT & Database AssistantCommented:
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
 
ITsolutionWizardAuthor Commented:
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
Rob HensonIT & Database AssistantCommented:
It isn't code, Text to Columns is a standard feature. Follow the steps in my first post.
0
 
ITsolutionWizardAuthor Commented:
I mean the SQL
0
 
Rob HensonIT & Database AssistantCommented:
Sorry, don't know SQL. My earlier comment was merely a guess based on VERY limited knowledge.
0
 
Glenn RayExcel VBA DeveloperCommented:
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
 
frankhelkCommented:
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now