Remove Multiple Space in String using SQL Archives - Tech Insights https://reactconf.org/category/remove-multiple-space-in-string-using-sql/ Unveiling Tomorrow's Tech Today, Where Innovation Meets Insight Thu, 30 May 2013 06:57:00 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.2 https://i0.wp.com/reactconf.org/wp-content/uploads/2023/11/cropped-reactconf.png?fit=32%2C32&ssl=1 Remove Multiple Space in String using SQL Archives - Tech Insights https://reactconf.org/category/remove-multiple-space-in-string-using-sql/ 32 32 230003556 Remove Multiple Space in String using SQL https://reactconf.org/removemultiplespaceinsql/ https://reactconf.org/removemultiplespaceinsql/#respond Thu, 30 May 2013 06:57:00 +0000 http://www.sqlneed.com/2013/05/30/remove-multiple-space-in-string-using-sql/ How to replace multiple space characters in a row with a single space. For example, the string “22 Main      Steet       Roma ” should look like “’22 Main Steet Roma “. …

The post Remove Multiple Space in String using SQL appeared first on Tech Insights.

]]>
How to replace multiple space characters in a row with a single space. For example, the string “22 Main      Steet       Roma ” should look like “’22 Main Steet Roma.
MS SQL Server
Create Function
CREATE FUNCTION dbo.RemoveMSpaces (@Txt VARCHAR(MAX))
 RETURNS VARCHAR(MAX)
AS
BEGIN
 IF CHARINDEX(  ,@Txt) = 0
RETURN @Txt;
RETURN dbo.RemoveMSpaces(REPLACE(@Txt,   , ‘ ‘));
END
GO
****************END Function***********************
SELECT REPLACE(RTRIM(firstname),   , ‘ ‘) AS  MultipleSpace from emp where idx=1300
SELECT dbo.RemoveMSpaces(firstname) ASRemoveMultipleSpace
 From emp where idx=1300
Result

Oracle
Select Replace(replace(replace(replace(replace(data,
      ‘,’ ‘),’     ‘,’ ‘),’    ‘,’ ‘),’   ‘,’ ‘),’  ‘,’ ‘) as RemoveMultipleSpace,
length(data) from (select ’22 Main      Steet       Roma’ data from dual )
Result
 

The post Remove Multiple Space in String using SQL appeared first on Tech Insights.

]]>
https://reactconf.org/removemultiplespaceinsql/feed/ 0 59