Wednesday, May 3, 2017

RTRIM() in SQL Server


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


Syntax:


SELECT RTRIM(expression)


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



Example 1:
RTRIM() on text column.

SELECT * FROM TempDatabaseLog



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



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

SELECT * FROM TempDatabaseLog



SELECT DISTINCT [Event], RTRIM([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: