-2

I want to know how to remove space between first and second word. But it should not remove other spaces in the same column. (Using SQL) It looks like this,

No. 378, Bearly Road, Colombo.

I want to remove only the space between "No." and "378". After remove it should be like this,

No.378, Bearly Road, Colombo.
Liam
  • 27,717
  • 28
  • 128
  • 190
Nishan
  • 5
  • 2
  • If you want to do it in SQL why did you tag Java? – Dale K Jul 02 '20 at 02:51
  • 2
    Does this answer your question? [Replace first occurrence of substring in a string in SQL](https://stackoverflow.com/questions/38911588/replace-first-occurrence-of-substring-in-a-string-in-sql) – Dale K Jul 02 '20 at 03:10

2 Answers2

0

Try using String::replaceFirst (assuming you're doing this in Java).

str.replaceFirst(" ", "");

For SQL-Server check this.

chriptus13
  • 705
  • 7
  • 20
0
 SELECT STUFF('No. 1', CHARINDEX(' ', 'No. 1'), 1, '')
                    (or)
SELECT concat(left('No. 1',CHARINDEX(' ','No. 1')-1),substring('No. 1',CHARINDEX(' ','No. 1')+1,len('No. 1')))
K Viswagna
  • 99
  • 5