We're a community of 1076K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,075,612 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

Split Column by Pipe (Excel Text to Columns)

Example data in column1
2|3|3|3GES|5|3
|3|334|3ere||343

I would like to split this by pipes so I can update the corresponding other blank 6 columns in each row.

Example Col1 Col2 Col3 Col4 Col5 Col6 Col7
2|3|3|3GES|5|3 2 3 3 3GES 5 3

I hope this makes sense! Any help is greatly appreciated.

4
Contributors
5
Replies
1 Week
Discussion Span
9 Months Ago
Last Updated
6
Views
moone009
Junior Poster
105 posts since Mar 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

It is easy in Excel. Select the column with the data in it and make sure that the columns to the right of it are empty. Then under Data use the option for text to columns, select delimited text and select other and put the pipe for the delimiter. If you have empty columns make sure that the box is unchecked for "Treat multiple delimiters as one"

rch1231
Veteran Poster
1,040 posts since Sep 2009
Reputation Points: 142
Solved Threads: 154
Skill Endorsements: 12

Thank you I understand how to do this in excel but I wish to do this in SQL.

moone009
Junior Poster
105 posts since Mar 2010
Reputation Points: 10
Solved Threads: 2
Skill Endorsements: 0

I would do it before it gets to sql if I were you with perl (Linux or Windows) or VB (Windows). Perl has a split function that will parse the data based on a delimiter you supply. VB could do it several ways also. You can then use PERL or VB to import the data straight into the database.

rch1231
Veteran Poster
1,040 posts since Sep 2009
Reputation Points: 142
Solved Threads: 154
Skill Endorsements: 12

Make use of the string functions SUBSTRING() and CHARINDEX().

tessy7
Junior Poster in Training
52 posts since Apr 2008
Reputation Points: 15
Solved Threads: 3
Skill Endorsements: 0

you can use replace like this

update table
set column1 = replace(column1, '|', ' ')

May be this will solve your prob.
Regards

M.Waqas Aslam
Master Poster
743 posts since Aug 2011
Reputation Points: 50
Solved Threads: 120
Skill Endorsements: 2

This article has been dead for over three months: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
 
© 2013 DaniWeb® LLC
Page rendered in 0.3125 seconds using 2.69MB