Need to remove punctuation characters

  • Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Can you provide an example please?
    😎

  • The DDL and sample data will help us understand what you're dealing with.
    The third link in my signature contains guidance on asking questions and what's needed to provide a good, tested solution.

    Also, what constitutes a "new line" in you data and what punctuation characters do you want to remove?

    This doesn't sound difficult.  We just need some specifics on what you want to do.

  • This might help you.
    http://www.sqlservercentral.com/scripts/T-SQL/117890/

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2
  • Eirikur Eiriksson - Saturday, August 12, 2017 5:26 AM

    rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Can you provide an example please?
    😎

    E.g. input string is 'rh@ythm@#%' o/p should be 'rh@ythm' so all possible punctuation characters must be removed from end only.

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • rhythmk - Tuesday, August 15, 2017 11:45 AM

    Eirikur Eiriksson - Saturday, August 12, 2017 5:26 AM

    rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Can you provide an example please?
    😎

    E.g. input string is 'rh@ythm@#%' o/p should be 'rh@ythm' so all possible punctuation characters must be removed from end only.

    This is a piece of cake, have a look at what Luis posted and the original function mentioned there. Come back if you have any problems with that.
    😎
    We did some substantial work on optimising this functionality and many good people pitched in on it, doubt you are going to find anything more efficient.

  • rhythmk - Tuesday, August 15, 2017 11:45 AM

    Eirikur Eiriksson - Saturday, August 12, 2017 5:26 AM

    rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Can you provide an example please?
    😎

    E.g. input string is 'rh@ythm@#%' o/p should be 'rh@ythm' so all possible punctuation characters must be removed from end only.

    what about  'rh7ythm321' ,,,,are you expecting ' 'rh7ythm'

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • J Livingston SQL - Tuesday, August 15, 2017 12:09 PM

    rhythmk - Tuesday, August 15, 2017 11:45 AM

    Eirikur Eiriksson - Saturday, August 12, 2017 5:26 AM

    rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Can you provide an example please?
    😎

    E.g. input string is 'rh@ythm@#%' o/p should be 'rh@ythm' so all possible punctuation characters must be removed from end only.

    what about  'rh7ythm321' ,,,,are you expecting ' 'rh7ythm'

    yes

    --rhythmk
    ------------------------------------------------------------------
    To post your question use below link

    https://www.sqlservercentral.com/articles/forum-etiquette-how-to-post-datacode-on-a-forum-to-get-the-best-help
    🙂

  • maybe....

    DECLARE @s-2 VARCHAR(100)= 'rh@ythm@#%';
    SELECT SUBSTRING(@s,1, LEN(@s)-(PATINDEX('%[A-Za-z]%', REVERSE(@s))-1))

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • rhythmk - Friday, August 11, 2017 11:22 PM

    Hi, 
    I need to remove any punctuation characters at the end and before new line.
    Please help.

    Ok... your turn. 😉  What will you be using this for?

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 10 posts - 1 through 9 (of 9 total)

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