/ Published in: SQL

Removes extra spaces from a string in SQL Server.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
CREATE FUNCTION [dbo].[RemoveSpaces] (@Str VARCHAR(MAX)) RETURNS VARCHAR(MAX) AS BEGIN SET @str = REPLACE(@str,' ','{}') SET @str = REPLACE(@str,'}{','') SET @str = REPLACE(@str,'{}',' ') RETURN @str END
Comments
