Link to home
Start Free TrialLog in
Avatar of robthomas09
robthomas09

asked on

SQL Syntax - Remove blank space Padding from string

I have data stored in a string column, and it has white space blank padding on either side:

table: person

name
'     john   '
' jane  '

I would like to remove the left and right space padding on either side - and the padding length is unknown.
Something like:?

Left(name, CHARINDEX (' ', name, CHARINDEX (' ', name) + 1) - 1)

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of rushShah
rushShah
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
TRIM(name) will do the job for you.
Sorry TRIM is not there in SQL Server. rushShah is correct. You can also use:
SELECT rtrim(ltrim(name))
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of robthomas09
robthomas09

ASKER

thanks - will try and let you know