T-SQL Tutorial

How to remove left space from a string


To remove the left space from a string uses sql LTRIM function. The LTRIM function delete spaces from the left of the string.

Syntax

LTRIM ( character_expression )

Example

SELECT LTRIM('   Test') AS Result;

Result
Test


Example

DECLARE @var_string varchar(100);
SET @var_string = '      Test remove the left space.';
SELECT LTRIM(@var_string);
GO

Result
Test remove the left space.