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.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Parsing the Character Column

Author  Topic 

rkumar28
Starting Member

49 Posts

Posted - 2006-01-06 : 13:37:52
I have am trying to do parse two character column.

Table1: has two columns:

Pol (Char) TifId (Char)
0AB012345PI 123456 001 345
0AB0234PI 1234567 004 123
0CD12345678PI 456789012 400 345

In Pol column, how to extract AB012345 from 0AB012345PI. Want to remove 0 from the beginning and remove PI at the end.

In TifId column, how to extract all the letters before the first space. I am trying to grab 123456 from 123456 001 345 and 456789012 from 456789012 400 345 ( needs to extract anything before the first space).


Will appreciate any advice on this.

Thanks


Raj

nr
SQLTeam MVY

12543 Posts

Posted - 2006-01-06 : 13:40:53
select substring(pol, 2, len(pol) - 3), substring(TifId, charindex(' ', TifId) -1)
from tbl


==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page
   

- Advertisement -