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 |
|
anjali5
Posting Yak Master
121 Posts |
Posted - 2012-05-18 : 19:12:48
|
Hi All, I have the data below in col1col1AB:5 AB:9 EF:5 EF:180 CD:12 AB:12 I want top parse it as below.Col1 AB CD EFAB:5 5AB:9 EF:5 9 5EF:180 180CD:12 AB:12 12 12 How can I acheive this |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2012-05-18 : 22:59:25
|
[code]select col1, case when col1 like '%AB%' then substring(col1, charindex('AB', col1) + 3, charindex(' ', col1 + ' ', charindex('AB', col1)) - charindex('AB', col1) - 3) end, case when col1 like '%CD%' then substring(col1, charindex('CD', col1) + 3, charindex(' ', col1 + ' ', charindex('CD', col1)) - charindex('CD', col1) - 3) end, case when col1 like '%EF%' then substring(col1, charindex('EF', col1) + 3, charindex(' ', col1 + ' ', charindex('EF', col1)) - charindex('EF', col1) - 3) endfrom tbl[/code] KH[spoiler]Time is always against us[/spoiler] |
 |
|
|
anjali5
Posting Yak Master
121 Posts |
Posted - 2012-06-28 : 13:54:42
|
| Thanks!! |
 |
|
|
|
|
|
|
|