Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniuNí thacaítear leis an mbrabhsálaí seo a thuilleadh.
Uasghrádú go Microsoft Edge chun leas a bhaint as na gnéithe is déanaí, nuashonruithe slándála, agus tacaíocht theicniúil.
Applies to:
SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
Analytics Platform System (PDW)
SQL analytics endpoint in Microsoft Fabric
Warehouse in Microsoft Fabric
Returns a character string after truncating all leading spaces.
Removes space character char(32)
or other specified characters from the start of a string.
Transact-SQL syntax conventions
Syntax for SQL Server prior to SQL Server 2022 (16.x):
LTRIM ( character_expression )
Syntax for SQL Server 2022 (16.x) and later, Azure SQL Managed Instance, Azure SQL Database, Azure Synapse Analytics, and Microsoft Fabric:
Tábhachtach
You need your database compatibility level set to 160 to use the optional characters argument.
LTRIM ( character_expression , [ characters ] )
An expression of character or binary data. character_expression can be a constant, variable, or column. character_expression must be of a data type, except text, ntext, and image, that is implicitly convertible to varchar. Otherwise, use CAST to explicitly convert character_expression.
A literal, variable, or function call of any non-LOB character type (nvarchar, varchar, nchar, or char) containing characters that should be removed. nvarchar(max) and varchar(max) types aren't allowed.
Returns a character expression with a type of string argument where the space character char(32)
or other specified characters are removed from the beginning of a character_expression. Returns NULL
if input string is NULL
.
To enable the optional characters positional argument, enable database compatibility level 160
on the database that you connect to when executing queries.
The following example uses LTRIM to remove leading spaces from a character expression.
SELECT LTRIM(' Five spaces are at the beginning of this string.');
Here's the result set.
---------------------------------------------------------------
Five spaces are at the beginning of this string.
The following example uses LTRIM
to remove leading spaces from a character variable.
DECLARE @string_to_trim VARCHAR(60);
SET @string_to_trim = ' Five spaces are at the beginning of this string.';
SELECT
@string_to_trim AS 'Original string',
LTRIM(@string_to_trim) AS 'Without spaces';
GO
Here's the result set.
Original string Without spaces
----------------------------------------------------- ---------------------------------------------
Five spaces are at the beginning of this string. Five spaces are at the beginning of this string.
Tábhachtach
You need your database compatibility level set to 160
to use the optional characters argument.
The following example removes the characters 123
from the beginning of the 123abc.
string.
SELECT LTRIM('123abc.' , '123.');
Here's the result set.
abc.
Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniu