Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
lcpx
Yak Posting Veteran
54 Posts |
Posted - 2005-10-20 : 20:36:02
|
| Hi,I got a question on SQL. One table, structure like this: (2 columns)A 123,456,789B 012,345C 678,901,234How to get the final result like below:A 123,A 456,A 789B 012,B 345,C 678,C 901,C 234Do I have to use PL/SQL? If so, how should I do it? Appreciate any thought you have on it!Cheers,Ken |
|
|
robvolk
Most Valuable Yak
15732 Posts |
|
|
Beaumondo
Starting Member
2 Posts |
Posted - 2005-10-22 : 12:18:49
|
| HiI create the tables "Category" and "Number" and used substring and union to split the data. SELECT Category, SUBSTRING(Number, 1, 4) AS NumberFROM SQLSPLITUNIONSELECT Category, SUBSTRING(Number, 5, 4)FROM SQLSPLITUNIONSELECT Category, SUBSTRING(Number, 9, 4)FROM SQLSPLITIt's a bit messy and i'm sure there's a better way to do it but i need to go out now so i'll have another look later or tomorrow. |
 |
|
|
Kristen
Test
22859 Posts |
Posted - 2005-10-23 : 00:54:55
|
| Search this post for "CSV" and "SPLIT"See also Best split functionKristen |
 |
|
|
lcpx
Yak Posting Veteran
54 Posts |
Posted - 2005-10-24 : 14:55:20
|
| Thanks very much for above responses! |
 |
|
|
|
|
|
|
|