How I can remove all NewLine from a variable in SQL Server?
sql, sql-server, sql-server-2008-r2, t-sql
Solution
You must use this query
Declare @A NVarChar(500);
Set @A = N' 12345
25487
154814 ';
Set @A = Replace(@A,CHAR(13)+CHAR(10),' ');
Print @A;
Problem
How can I can remove all NewLine from a variable in SQL Server? I use SQL Server 2008 R2. I need remove all NewLine in a variable in a T-Sql Command. For example: ``` Declare @A NVarChar(500) Set @A = ' 12345 25487 154814 ' Print @A ``` And it printed like this: ``` 12345 25487 154814 ``` But I want to get strings like this: 12345 25487 154814 I write this query, but it does not work: ``` Set @A = Replace(@A,CHAR(13),' ') ```