Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How Do I strip a set of numbers from a VarChar Column

Status
Not open for further replies.

jabmod

MIS
Sep 12, 2004
68
US
I have a column that is 8 characters in lenght.

The values in starts with:
1) a set of numbers varies in lenght
2) next is 2 spaces
3) then a set of characters that varies in lenght starting with P and tries to spell the word Point.

Examples are:
699 Poi
1,314 P
90 Poin
0 Point

I would like to pull only the numbers from this column so I can now have
699
1,314
90
0

Thanks for your help





 
Since it will always be a number followed by a space...

Code:
Select Left(Field, CharIndex(' ', Field)-1)
From   SomeTable

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Code:
SELECT LEFT(MyField, CHARINDEX(MyField,' ')-1) AS MyField
       FROM MyTable
This will works ONLY if first you didn't have a space between digits.

Borislav Borissov
VFP9 SP1, SQL Server 2000/2005.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top