Pages

Sunday, December 4, 2011

How to trim on mssql

Trim is a standard function which is used by many programming languages to remove the space character in a string. For example ' Hello world ', with trim function, it will be 'Hello world'.

In SQL Server, trim function is not provided by default. We need to do a certain trick to remove the spaces. we can use LTRIM and RTRIM function together.

Here's an example to remove spaces in SQL Server:
select LTRIM(RTRIM(' Hello world '))

No comments:

Post a Comment

Don't Forget To Join Our Community
×
Widget