Question: I have this column

```
NAME
John Stephenson
James Martin
Anna Corelia

```

How I can select this column to this?

```
NAME
Stephenson, John
Martin, James
Corelia, Anna 

```

Answer: 
Your question has nothing to do with `TRIM()` function. Probably you are trying to get something like below using `LEFT()` and `RIGHT()` function of `SQL Server` and concatanating them with `,`

```
select right('John Stephenson',(len('John Stephenson')-charindex(' ','John Stephenson')))
+ ', ' + left('John Stephenson',(charindex(' ','John Stephenson') - 1))

```

which will result in 

```
Stephenson, John

```
There is no a single trim function but you can 

```
 select   ltrim(rtrim(colname)) from tablename 

```

which will TRIM both sides.

but what you need is:

```
declare @name varchar(300) ='Stephenson John';
Select  

Substring(@name, 1,Charindex(' ', @name)-1) +
', '  +
Substring(@name, Charindex(' ', @name)+1, LEN(@name))
 as name

```

Sorry I miss post