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

```
```
SELECT substring(NAME+', '+NAME,charindex(' ',NAME)+1,len(NAME)+1) FROM MyTable

```

This also turns `"Rip Van Winkle"` into `"Van Winkle, Rip"`

**[SQL Fiddle Demo](http://sqlfiddle.com/#!3/d4a53/1)**