July 3, 2013 at 8:24 am
Hi All
I need one logical help to implement in my main logic.
so please help me to do
create table #x1
(SchoolID int,
SchoolName Varchar(50))
INSERT INTO #x1 VALUES (101,'CITY CONNECTIONS-WEST')
INSERT INTO #x1 VALUES (102,'City Connections - South')
I need space around hyphens where SchoolName has no space around Hyphes.
SchoolIDSchoolName
101CITY CONNECTIONS-WEST
102City Connections - South
Expected output is as below
SchoolIDSchoolName
101CITY CONNECTIONS - WEST
102City Connections - South
Please help me to do this
Thanks for Your Help
July 3, 2013 at 8:28 am
SELECT SchoolID
,REPLACE(REPLACE(SchoolName, '-',' - '),' - ',' - ') AS SchoolName
FROM #x1
July 3, 2013 at 2:01 pm
Eugene Elutin (7/3/2013)
SELECT SchoolID
,REPLACE(REPLACE(SchoolName, '-',' - '),' - ',' - ') AS SchoolName
FROM #x1
Hi
Unfortunately this will leave double spaces for strings like 'One -two'
A little change
SELECT SchoolID
,REPLACE(REPLACE(SchoolName, '-',' - '),' ',' ') AS SchoolName
FROM #x1
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply