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 |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2002-11-11 : 10:33:55
|
| sonny singh writes "Hi folksI have situation where i need to extract text letters(a-z) from alphanumeric string. for example:if I need to extract first text letters from this stock_code HA031/51629A,,, and CAS255/EX-226. now it could be any number of first text letters but always first in the stock_code. I only need to extract letters. I have tried substring and charindex functions and can extract it like below:-substring(t2.stock_code,1,(abs(charindex('/',T2.stock_code)-4))) = T4.manuf_short_code but problem is if stock_code like this :- HA031629 then above formula won't work.. so need to read from left. I have found he LEFT and ISNUMERIC functions but they no good so far..so which function and how should solve this my problem???please could any one help me in this..thanks in advancesonny singhsinghsonny@hotmail.com" |
|
|
Arnold Fribble
Yak-finder General
1961 Posts |
Posted - 2002-11-11 : 10:48:17
|
LEFT(t2.stock_code, PATINDEX('%[^a-z]%', t2.stock_code + '0')-1) |
 |
|
|
|
|
|