HI WELCOME TO KANSIRIS

SQL Server Replace Multiple Spaces in String with Single Space

Leave a Comment
Now I will explain how to replace multiple spaces in string with single space in sql server.

To replace multiple spaces in string with single space in sql server we need to write the query like this


Select REPLACE(REPLACE(REPLACE(@str,' ','{}'),'}{',''),'{}',' ')
Example

DECLARE @str varchar(150)
SET @str='Hello    Welcome   to   siri's.com'
Select REPLACE(REPLACE(REPLACE(@str,' ','{}'),'}{',''),'{}',' ')

0 comments:

Post a Comment

Note: only a member of this blog may post a comment.