Tuesday, May 2, 2017

LTRIM() in SQL Server


SQL LTRIM() function is used to remove all the leading white spaces from the string. LTRIM() removes all the white spaces at the left side of the first character of the string. LTRIM() takes only one parameters i.e. string and returns the string with removed leading white spaces. LTRIM() does not works on NULL Values, NULL values are not considered.


Syntax:


SELECT LTRIM(expression)


expression is the text from which leading spaces need to be removed.



Example 1:
LTRIM() on text column.

SELECT * FROM TempDatabaseLog



SELECT DISTINCT [Event], LTRIM([Event]) FROM TempDatabaseLog



Example 2:
LTRIM() on column with NULL values.

SELECT * FROM TempDatabaseLog



SELECT DISTINCT [Event], LTRIM([Event]) FROM TempDatabaseLog



Share This
Previous Post
Next Post

TekGrabs, established in 2017, is in the business of sharing Information. It provides news, articles and photos about the different technologies, inventions in different domains. Provides information on programming and databases.

0 comments: