Groups | Blog | Home
all groups > sql server misc > april 2006 >

sql server misc : How to get a character from a string


hon123456
4/13/2006 3:09:34 AM
Dear all,

I have a field with String type. The format is like that e.g
12345a 23456b or 12345 . The last english character of the field is
optional. Now I need to determine whether the last english character
exist, if it exist, then I need to extract the last english character.
for example, if the field is 12345b, then the character extracted is b,
if the field is 12345c, then the character extracted is c, if the field
is 12345, then no character is extracted. How can I perform this task
in sql statement?

Thanks
RBarryYoung NO[at]SPAM gmail.com
4/13/2006 11:51:37 AM
Select Case When IsNumeric(Right(StringField, 1))=1Then ''
Else Right(StringField, 1)
From YourTable


-- rBYoung
hon123456
4/14/2006 11:07:20 PM
Dear rBYoung,

IF I have two fields to select, can I write as follows:

select case....then ...else.., case...then..else..,
fieldsA from TableA

Thanks for your reply.
AddThis Social Bookmark Button