all groups > sql server mseq > september 2006 >
You're in the

sql server mseq

group:

Break out Pipe Values



Break out Pipe Values Phil
9/26/2006 6:00:02 AM
sql server mseq: Hi.

I am trying to clean up some data and I need to seperate out some values, I
have a table that looks something like this.

EmploymentID Areas
101 |1.2|1.3|1.4|
716 |2.3|2.4|2.5|
671 |3.4|3.5|3.6|

What I want it to look like is as follows

EmploymentID Areas
101 |1.2|
101 |1.3|
101 |1.4|
716 |2.3|
716 |2.4|
716 |2.5|
671 |3.4|
671 |3.5|
671 |3.6|

There can be more than 3 lots of numbers, I have just done this as an example
The EmploymentID is an (int) and the Areas (varchar(255))

Thanks for any help

Re: Break out Pipe Values Arnie Rowland
9/26/2006 8:09:24 AM
You are treating a field like an array. It's not really a good idea -as you
are finding out.

Look up the use of patindex() in Books Online. I think that you will become
very good at using patindex().

Also, these resources may help you.

Arrays and Lists in SQL Server
http://www.sommarskog.se/arrays-in-sql.html
http://www.realsqlguy.com/?p=9
http://www.aspfaq.com/2248
http://realsqlguy.com/twiki/bin/view/RealSQLGuy/ParseDelimitedStringToTable
2005-
http://omnibuzz-sql.blogspot.com/2006/06/interesting-queries-using-recursive.html


--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

Re: Break out Pipe Values Phil
9/26/2006 11:14:02 AM
Hi Arnie,

Thanks for the response, those links were great.

The only problem that I have is that I need the employment ID each time I
get one of the area codes and the code from the links just breaks up the area
codes but does not allow me to get any other fields of data, if you can offer
and more advice or links it would be much appreciated.

Thanks Phil

[quoted text, click to view]
Re: Break out Pipe Values Arnie Rowland
9/26/2006 12:17:09 PM
I'm sure, that if you will look though that material again, you will see
that it is a easy task to include additional columns from the table -even as
you are deconstruction a single field.

Having the deconstructed data, without any way to relate it to the remainder
of the data would be worthless -n'est-ce pas?

--
Arnie Rowland, Ph.D.
Westwood Consulting, Inc

Most good judgment comes from experience.
Most experience comes from bad judgment.
- Anonymous


[quoted text, click to view]

AddThis Social Bookmark Button