>> I'd like to strip various leading characters from a

>> registration number.

>> for example

>> MA1234 = 1234

>> 987651 = 987651

>> Q10001 = 10001

>>

>> The code below works but it's gotta be inefficient(and I

>> have to account of all lengths). I thought I could use a

>> WHILE loop that loops through the length of each value

>> checking if it's numeric or not.

>> Something like ....

>>

>> SELECT Code =

>> CASE

>> WHILE X <> Len(Code)

>> IF isnumeric(right(Code,x)) = 1

>> right(code,x)

>> BREAK

>> ELSE

>> SET x = x + 1

>> END

>>

>> ..But no matter how variations of this I try it won't

>> work. I can get a much larger cursor based SP working

>> along these lines but I don't understand why this Set-

>> Based code does not work, Any comments appreciated.

>>

>>

>> SELECT code =

>> CASE

>> WHEN isnumeric(right(Code,8)) = 1 THEN right(code,8)

>> WHEN isnumeric(right(code,7)) = 1 THEN right(code,7)

>> WHEN isnumeric(right(code,6)) = 1 THEN right(code,6)

>> WHEN isnumeric(right(code,5)) = 1 THEN right(code,5)

>> WHEN isnumeric(right(code,4)) = 1 THEN right(code,4)

>> WHEN isnumeric(right(code,3)) = 1 THEN right(code,3)

>> ELSE

>> null

>> END

>> FROM Table

## Bookmarks