removing character (Letters only)

  • Hello comunity

    I need to build a query, or use a function to removing alfabetic Character from a string.

    My string is

    WI14000323-0003

    the value i want to keep is : 14000323-0003.

    I try using this SELECT:

    SELECT STUFF(Upper(z.lote), PATINDEX('%[A-Z]%', Upper(z.lote)), 2, '') from mytable

    but in this case i have only 2 letters WI, but in the future i dont know if is only 2 letters, 1 letter or more, then is not what i pretend.

    Someone could give a suggestion.

    Best regards,

    Luis Santos

  • take a look at this thread for some high performance strip-non-numeric functions.

    you would need to change it so that it also allows dashes, but that's a trivial tweak:

    do you have a StripNonNumeric ITVF function?

    i've taken that and made versions for Non-Alphanumeric,Non-AlphaBetical,and some similar custom versions to allow certain punctuation.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Hello Lowell

    Thanks for your reply.

    Best regards,

    Luis Santos

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply