sql trim all spaces code example

Example 1: sql remove spaces

SELECT TRIM('   Exemple   ');						-- 'Exemple'
SELECT LTRIM('   Exemple   ');						-- 'Exemple   '
SELECT RTRIM('   Exemple   ');						-- '   Exemple'
SELECT TRIM(BOTH 'x' FROM 'xxxExemplexxx');			-- 'Exemple'
SELECT TRIM(LEADING 'x' FROM 'xxxExemplexxx');		-- 'Exemplexxx'
SELECT LTRIM('xxxExemplexxx', 'x');					-- 'Exemplexxx'
SELECT TRIM(TRAILING 'x' FROM 'xxxExemplexxx'); 	-- 'xxxExemple'
SELECT RTRIM('xxxExemple', 'x');					-- 'Exemplexxx'

Example 2: sql trim all spaces

Select TRIM (' Word  ')

Example 3: remove spaces sql 2008

SELECT RTRIM(LTRIM(' Word '))

Example 4: remove all spaces from string sql

SELECT REPLACE(' Hello World ',' ')

Tags:

Sql Example