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 |
|
Tmclauch
Starting Member
2 Posts |
Posted - 2009-05-28 : 12:40:00
|
I have a Sql view that require that I parse the column into two separate fields for a report. There are mulitple spaces between the two sets of data, but the data is not the same length in every case. Example of field 1234654M 8563241 Tina P McLauchlan |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-28 : 13:06:46
|
| [code]SELECT CASE WHEN CHARINDEX(' ',YourField)>0 THEN LEFT(Yourfield,CHARINDEX(' ',YourField)-1) ELSE YourField END AS FirstData,CASE WHEN CHARINDEX(' ',YourField)>0 THEN LTRIM(SUBSTRING(YourField,CHARINDEX(' ',YourField)+1,LEN(YourField))) ELSE NULL END AS SecondDataFROM YourTable[/code] |
 |
|
|
Tmclauch
Starting Member
2 Posts |
Posted - 2009-05-28 : 14:02:38
|
| Solution worked... Thank you very much.Tina P McLauchlan |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2009-05-28 : 14:08:28
|
| welcome |
 |
|
|
|
|
|