Replacing Carriage Return or New Line Characters in SSRS
Text formatting inside of a SSRS textbox can sometimes be tricky and this case is no exception. At the core we are using the built in REPLACE function. REPLACE takes the following parameters:
1) The string to search in (usually your field value)
2) What to search for
3) What to replace it with
There are some other optional parameters as well, but we aren’t going to focus on those. So where this becomes tricky is in the “what to search for”. You may think that you can search for “\r\n”, but that would be incorrect. What is needed is the CHR function. CHR(10) in particular. If you head out to http://www.asciitable.com/ you will see that character 10 is the new line character. Which makes sense for our search.
What you will end up with is something that looks like the following:
=REPLACE(<string to search in>, CHR(10), <string to replace with>)
If this still doesn’t get you the desired result, you may need to wrap the replace with another replace. This time you will be searching for CHR(13) (carriage return).
=REPLACE(REPLACE(<string to search in>, CHR(13), “”), CHR(10), <string to replace with>)