Removing Space between Names

Kirthiga
Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 787
Declare @temp table(Name varchar(50))
insert into @temp values
('Raja Rao'),('Arul Pandi'),('Mahesh Babu'),('Suresh Kumar')

Select Name [Name with Space]
,Substring(Name,0,charindex(' ',Name))+
LTRIM(Substring(Name,charindex(' ',Name)+1,LEN(Name)-charindex(' ',Name))) [Name without Space]
from @temp

Comments or Responses

Login to post response