Replace enter with space

Ali picture Ali · Nov 21, 2012 · Viewed 41.6k times · Source

How can i replace "Enter" in one of fields in the database with space

actually I have tried the below codes in vb.net, but non of them is working for me ,,

 address = Replace(address, System.Environment.NewLine, " ")

or

address = Replace(address, vbNewLine, " ")

or

address = Replace(address, Chr(13), "")

Language : Vb.net database : MSSQL 2005

Thanks in advance

Answer

Tim Schmelter picture Tim Schmelter · Nov 21, 2012

If you want to replace new-line chars in SQL-Server.

  • Line Feed – CHAR(10)
  • Carriage Return – CHAR(13)

So if you want to update a column and replace NewLines with white-spaces:

UPDATE TableName SET address=REPLACE(REPLACE(address, CHAR(13),' '), CHAR(10),' ');