How to remove Line Break when selecting data from SQL Server

When you run SELECT query and copy the result to notepad or excel instead of one row columns with new line character shifts to new row. char(13) is carriage return (is a control character or mechanism used to reset a device's position to the beginning of a line of text) and char(10) is line feed (new line).

Below query will eliminate carriage return and new lines from a column of a table.

28628342

The inner replace replaces line feed and the outer replace replace carriage return
SELECT Replace(Replace(X_DIVISION,CHAR(10),''),CHAR(13),'') FROM S_CASE_X WHERE PAR_ROW_ID = '1-8I4G98D'


Source: Stackoverflow 28628342, Wikipedia

See Also:

How to remove Line Breaks from a string using Siebel eScript

← Back to Home

Comments

Post a Comment