9

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

Ali
  • 664
  • 3
  • 13
  • 21

2 Answers2

23

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),' ');
Tim Schmelter
  • 450,073
  • 74
  • 686
  • 939
6
  • Line Feed – CHAR(10)
  • Carriage Return – CHAR(13)
  • Tab char(9)

    REPLACE(REPLACE(REPLACE(address, CHAR(13),' '), CHAR(10),' '), CHAR(9),' ')

Tanmay Nehete
  • 2,138
  • 4
  • 31
  • 42