1 min read

Remove carriage return / Line feeds in string and output with quotes

I have the following SQL that outputs a string with double quotes around it:

SELECT '"'+A.DESCR+'"'
FROM MyTable

Results:
"Stackable Storage Basket"

I have found that I have carriage returns / line feeds in some of the data and want to remove any of these while retaining the quotes. I have modified the code as below, however this is adding an extra quote onto the end of the string, and not retaining the beginning quote either.

SELECT REPLACE(REPLACE(DESCR + '"'+DESCR+'"' + '''', char(10),'"'), char(13), '"')
FROM MyTable

Results:
Stackable Storage Basket"'

How do I need to modify this to get the expected behavior?