user1296762
user1296762

Reputation: 512

RTRIM from replace

I have used a replace statement to I have @@@ after the name of the customer MR@BOB@REED@@@@@@@@@@@@@@@@@@@@@@@

I now want to get rid of the @ after reed.

I tried:

select RTRIM(Name2,'@')

But I get the error

The rtrim function requires 1 argument(s).

Upvotes: 1

Views: 3687

Answers (2)

Seasoned
Seasoned

Reputation: 1059

select substring(Name2,0,charindex('@@',Name2)) from table

In above query, 'Name2' is the name of the column and table is the name of the 'table' containing that column.

Upvotes: 1

podiluska
podiluska

Reputation: 51504

RTRIM removes trailing spaces.

You probably want LEFT or SUBSTRING

eg

select left('@mr@bob@reed@@@@@@@', charindex('@@','@mr@bob@reed@@@@@@@'))

Upvotes: 2

Related Questions