Replace enter with space
Asked Answered
L

2

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

Loria answered 21/11, 2012 at 9:30 Comment(2)
new lines are \n\r in windows, so try Chr(13) and Chr(10).Hamforrd
thank you so much , Chr(10) worksLoria
A
24

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),' ');
Abbate answered 21/11, 2012 at 9:44 Comment(0)
D
7
  • Line Feed – CHAR(10)
  • Carriage Return – CHAR(13)
  • Tab char(9)

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

Dermott answered 3/9, 2014 at 10:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.