Categories: SQL server 2017

Trim function in sql server 2017

Before Sql server 2017 we only had LTRIM and RTRIM function available to remove spaces from left and right separately.  With trim function now being available in sql server 2017 it can be used for two purposes.

Lets look at the syntax of Trim function  first.

TRIM ( [ characters FROM ] string )

Trim in sql server 2017 can be used to remove space character or other characters from the start and the end of the string.

Lets now look at the two usage of trim function with example.

  1. It can be used to remove the the space from the left and right side of the string.
  2. It can be used to remove the space and any specified character from left or right of the string.

SELECT TRIM( ‘ sqlag ‘) AS RESULT, ‘First example’
SELECT TRIM( ‘. , #’ FROM ‘ # sqlag . ‘) AS RESULT,’Second example’

 

Trim in Sql server 2017

 

 

 2,006 total views,  2 views today

admin

Share
Published by
admin

Recent Posts

What is slow changing dimension?

The attribute value in Dimension table are going to change slowly over time and they…

5 years ago

How to Change SQL Server Compatibility level

  Changing Database compatibility level will be required when you upgrade your database from one…

6 years ago

View Compatibility level of Database

To know what is compatibility Level check this post link. You can view the compatibility…

6 years ago

SQL Server Compatibility Level

SQL Server Compatibility level will be used to decide how SQL will use it features.…

6 years ago

View in SQL server

A view is a virtual table.  View will not store any data physically. The data…

6 years ago

SSIS :The package failed to load due to error 0xC0011008

Below is the error which I was getting today while deploying the SSIS pacakge for…

6 years ago