How to trim spaces in column values in sql server 2008?

In this post, we will discuss how we can get trims values of a column in SQL server 2008.

New to Office 365 SharePoint Online? Get Office 365 Enterprise E3 Subscription & Try out all the features

Also, you can check out my previous posts on:

– Logging In Users Programmatically in Asp.Net

– How to get distinct data from tables in SQL server 2008?

– Tutorial on Tuple in C#.Net 4.0

Suppose you have a column name as firstname of varchar type and if it contains any white spaces then when you run the select sql statement like below,

Select firstname from employees

Then it will return all the firstname of all the employees but also the whitespaces will come if any with the names.

so to trim the spaces you can write the select sql statement like below:

SELECT LTRIM(RTRIM(firstname)) AS FirstName from employees

This will trim the whitespaces from the column values.

Check out Best Alternative to InfoPath -> Try Now


(Installation & Features)

About Bijay Kumar

I am Bijay from Odisha, India. Currently working in my own venture TSInfo Technologies in Bangalore, India. I am Microsoft Office Servers and Services (SharePoint) MVP (5 times). I works in SharePoint 2016/2013/2010, SharePoint Online Office 365 etc. Check out My MVP Profile.. I also run popular SharePoint web site

View all posts by Bijay Kumar →