Please help — Renascent. This solution works in the special case when there are more than 4 charactersin column which is the case for the OP but fails otherwise.
I got the answer to my own question, ant this is: select reverse stuff reverse 'a,b,c,d,' , 1, N, '' Where N is the number of characters to remove. Community Bot 1 1 1 silver badge. Fernando Torres Fernando Torres 7 7 silver badges 18 18 bronze badges. Raj Baral 6 6 silver badges 19 19 bronze badges.
Daren Daren 4 4 silver badges 5 5 bronze badges. This should do it, removing characters from the left by one or however many needed. Spieker 6, 7 7 gold badges 42 42 silver badges 50 50 bronze badges. Peter Tountas Peter Tountas 31 4 4 bronze badges. Milan Milinkovic Milan Milinkovic 1 1 1 bronze badge. Sign up or log in Sign up using Google. Sign up using Facebook.
Sign up using Email and Password. Asked 12 years, 5 months ago. Active 1 year, 5 months ago. Viewed k times. Daveed Daveed 1, 2 2 gold badges 11 11 silver badges 5 5 bronze badges. Add a comment. Active Oldest Votes. Shiroy 1, 1 1 gold badge 12 12 silver badges 20 20 bronze badges. Volvox it will still throw exception if the string is Empty String, i am modifying your answer to handle this scenario.
Bill Hoenig Bill Hoenig 1, 1 1 gold badge 7 7 silver badges 2 2 bronze badges. Nice, using this with an outer apply, with a for xml path '' to eliminate a trailing comma. Also the same way as Tracker1. It is really remarkable how brutal SQL can be sometimes. This is incredible. Thanks, it helped me, in my case i had a last space so the first index is 2 select reverse stuff reverse 'a,b,c,d,' , 2, 1, '' — Arngue.
Try this: select substring 'test string', 1, len 'test string' - 1. Adrien Adrien 2, 20 20 silver badges 17 17 bronze badges.
Adrien any idea why this seems to give the same result as select substring 'test string', 0, len 'test string'? Now, both queries return the same because the numbering is 1 based, meaning that the first character in the expression is 1. If start is less than 1, the returned expression will begin at the first character that is specified in expression. Source — JS5. Worked nicely in removing last 4 characters by changing the last part to - 4 — straville. Maxim Grachev Maxim Grachev 3 3 silver badges 5 5 bronze badges.
David Rogers 2, 2 2 gold badges 34 34 silver badges 73 73 bronze badges. David Roach David Roach 2 2 silver badges 6 6 bronze badges. This is an Underrated comment, it's fast and it doesn't have to select the string twice to work. Sagar V The best answers are voted up and rise to the top. Stack Overflow for Teams — Collaborate and share knowledge with a private group. Create a free Team What is Teams?
Learn more. Remove last character in selected column? Ask Question. Asked 7 years, 7 months ago. Active 4 years, 5 months ago. Viewed 22k times. Improve this question. Add a comment. Active Oldest Votes.
0コメント