| Author |
Topic |
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2008-12-24 : 12:30:00
|
| Hi.I have a coulmn with these valuse:SANYO SCP-5300 L-ION 950mAhSANYO SCP-5300 LI-ION 1400mAhMOTOROLA V66 MB-C23 600mAh/BLUMOTOROLA T720 MLC-3 1.2Ah/SLVNEXTEL i95cl LN-KLM 1.4Ah/SLVRNEXTEL i530 PLK-POL 1400mAh....how can I get the second part from the end of them.I mean I need these results:L-IONLI-ION MB-C23 MLC-3 LN-KLM PLK-POL.thanks |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-24 : 13:00:48
|
| Select substring (Column,charindex(' ',Column,10)+1,(charindex(' ',Column,16)- Charindex(' ',Column,10))) from table |
 |
|
|
a.ashabi
Posting Yak Master
117 Posts |
Posted - 2008-12-24 : 13:22:30
|
| thank u so much :) |
 |
|
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-12-24 : 13:23:44
|
Welcome. Merry Christmas |
 |
|
|
Kumar_Anil
Yak Posting Veteran
68 Posts |
Posted - 2008-12-24 : 18:30:35
|
| Hello !!!I ran into a similar situation a while ago & here is what I had back then. This is bit yucky but this is what I used & it never failed me so far.regards,Anil Kumar.select left(substring(substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1),charindex(' ',substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1), 0)+1,len(substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1)) -charindex( ' ', substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1),0)+1),charindex(' ', substring(substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1),charindex(' ',substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1), 0)+1,len(substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1)) -charindex( ' ', substring (Column, charindex(' ', Column, 0)+1, len(Column) - charindex(' ', Column, 0)+1),0)+1))) |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-12-25 : 02:33:32
|
quote: Originally posted by a.ashabi Hi.I have a coulmn with these valuse:SANYO SCP-5300 L-ION 950mAhSANYO SCP-5300 LI-ION 1400mAhMOTOROLA V66 MB-C23 600mAh/BLUMOTOROLA T720 MLC-3 1.2Ah/SLVNEXTEL i95cl LN-KLM 1.4Ah/SLVRNEXTEL i530 PLK-POL 1400mAh....how can I get the second part from the end of them.I mean I need these results:L-IONLI-ION MB-C23 MLC-3 LN-KLM PLK-POL.thanks
if format is consistent with always 4 words you can use thisSELECT PARSENAME(REPLACE(column,' ','.'),2) FROM Table |
 |
|
|
|
|
|