Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 remove carriage return at end of string

Author  Topic 

MyronCope
Starting Member

46 Posts

Posted - 2011-04-06 : 14:27:32
using sql server 2005
I am returning a string and sometimes at the end of the string there is a carriage return. I only want to delete the carriage return at the end of the string if it exists.

how do I do this?
thanks

MC

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2011-04-06 : 14:40:06
If there is only a carriage return, you can do it as
replace(YourString,char(13),'')

But you may also have a line-feed (ascii code 10). If you want to remove that as well do this:
replace(replace(YourString,char(13),''),char(10),'')
Go to Top of Page
   

- Advertisement -