SQL query for a carriage return in a string and ultimately removing carriage return
I have some data in a table and there are some carriage returns in places where I
The main question was to remove the CR/LF. Using the replace and char functions works for me:
Select replace(replace(Name,char(10),''),char(13),'')
For Postgres or Oracle SQL, use the CHR function instead:
replace(replace(Name,CHR(10),''),CHR(13),'')
this will be slow, but if it is a one time thing, try...
select * from parameters where name like '%'+char(13)+'%' or name like '%'+char(10)+'%'
Note that the ANSI SQL string concatenation operator is "||", so it may need to be:
select * from parameters where name like '%' || char(13) || '%' or name like '%' || char(10) || '%'
this works: select * from table where column like '%(hit enter)%'
Ignore the brackets and hit enter to introduce new line.
Something like this seems to work for me:
SELECT * FROM Parameters WHERE Name LIKE '%\n%'
This also works
SELECT TRANSLATE(STRING_WITH_NL_CR, CHAR(10) || CHAR(13), ' ') FROM DUAL;
You can also use regular expressions:
SELECT * FROM Parameters WHERE Name REGEXP '\n';