none
how to get string before a number RRS feed

  • Question

  • Hi All

    i want the string before a number

    example case

    count4211

    parkcount3221

    digitalcount541

    i want count421,parkcount322,digitalcount54. I am aware of left and right but since they are not of fixed length all the times i am looking for a way. i want the '1' at the end to be removed

    please help

    Thanks


    • Edited by LisaKruger Wednesday, March 6, 2019 2:22 PM
    Wednesday, March 6, 2019 2:19 PM

Answers

  • DECLARE @TXT VARCHAR(MAX)='parkcount3221'
    SELECT SUBSTRING(@TXT,1,LEN(@TXT)-1)



    Ousama EL HOR

    [If a post helps to resolve your issue, please click the "Mark as Answer"  of that post or click Answered "Vote as helpful"  button of that post. By marking a post as Answered or Helpful, you help others find the answer faster. ]


     [User Page]     [MSDN Page]     [Blog]     [Linkedin]

    • Marked as answer by LisaKruger Wednesday, March 6, 2019 2:56 PM
    Wednesday, March 6, 2019 2:27 PM

All replies