Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Replace enter with space

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

like image 257
Ali Avatar asked Nov 21 '12 09:11

Ali


People also ask

How do you replace enters with spaces in Word?

Click on the Find button. To replace the hard return with a space character, type a space in the Replace with field, then click the Replace button. To replace the hard return with nothing (remove the character), click the Replace button (without entering anything in the Replace with field).

How do you replace all enters in space?

(1) In the Find What box press Ctrl + J keys to enter alt-enter character; (2) In the Replace with box type space or comma as you need; (3) Click the Replace All button.

How do you change a line break with spaces in Excel?

Press the Tab key on the keyboard, to move to the Replace With box. Type a space character. Click Find Next or Find All, to find the cells with line breaks. Click Replace or Replace All, to replace the line breaks with space characters.


2 Answers

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),' ');
like image 103
Tim Schmelter Avatar answered Sep 18 '22 14:09

Tim Schmelter


  • Line Feed – CHAR(10)
  • Carriage Return – CHAR(13)
  • Tab char(9)

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

like image 31
Tanmay Nehete Avatar answered Sep 19 '22 14:09

Tanmay Nehete