Introduction:
Here I will explain how to replace multiple spaces in string with single space in sql server or sql server replace multiple spaces with one space in string or sql server remove extra multiple spaces from string without using any while loop.
Here I will explain how to replace multiple spaces in string with single space in sql server or sql server replace multiple spaces with one space in string or sql server remove extra multiple spaces from string without using any while loop.
Description:
In
previous articles I explained replace function example in sql server, Query to remove first and last character from string in sql
server, remove html tags from string in sql, substring function in SQL server
and many articles relating to SQL
server.
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 Aspdotnet-suresh.com'
Select REPLACE(REPLACE(REPLACE(@str,' ','{}'),'}{',''),'{}',' ')
|
Once
we run above query we will get output like as shown below
Output:
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
4 comments :
good!!!!!!!!!!
Very Useful
Very Helpfull thanks
Great Help for Developers
Note: Only a member of this blog may post a comment.