remove first three character in sql serer

How do I in sql server to remove three first character that start with "RHB apps one". So I want teh result to be "apps one". How do I do this
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mark WillsTopic AdvisorCommented:
if it is a column, then use STUFF

select ltrim(stuff('RHB apps one',1,3,''))

the ltrim is to remove leading spaces

see :
motioneyeAuthor Commented:
I just want any character  value in  the column ColumnZ that start with RHB as first three character to be remove, so instead of  "RHB apps one" then the result should only appear "apps one"
Mark WillsTopic AdvisorCommented:
Yep, you do want STUFF - it is a real thing...

from yourdatasource
where columnz like 'RHB%'

and you can use that in an update... basically 'stuffing' a zero length string over the top of the first three characters.

your other choice is REPLACE, but it could replace any occurrence of RHB
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Shaun VermaakTechnical SpecialistCommented:
Isn't it four characters?
Bill PrewIT / Software Engineering ConsultantCommented:

Yes, I think that's why Mark proposed this initially...

select ltrim(stuff('RHB apps one',1,3,''))

Vitor MontalvãoMSSQL Senior EngineerCommented:
You can use the REPLACE function:
SELECT REPLACE(colName,'RHB ', '') 
FROM tableName

Open in new window

Mark WillsTopic AdvisorCommented:
Yes as I said before, you can use replace, but if it is the three characters (not 4 characters)

then replace(columnz,'RHB','')  will also make a string (column name) of "Regional Home Builders Association - RHBA" become "Regional Home Builders Association - A" and (depending on collation) it is case insensitive. So "Myrrhbearers" becomes "Myrearers". Replace is not position aware. So best used where position in not as easily determined.

As Bill kindly points out, the correct way to remove any resulting leading spaces is to use ltrim()

STUFF() is the correct command, and the only two other approaches would be SUBSTRING or RIGHT

SELECT RIGHT(COLUMNZ, len(columnz) - 3)

And still we need to wrap in ltrim()

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Vitor MontalvãoMSSQL Senior EngineerCommented:
Yes as I said before, you can use replace, but if it is the three characters (not 4 characters)
Why not 4? Replacing 3 characters will leave a leading space.
Mark WillsTopic AdvisorCommented:

You could, but the requirement was "remove three first character"

And the ltrim() removes any leading space(s) any way
Vitor MontalvãoMSSQL Senior EngineerCommented:
But requirement doesn't fits with the example as it doesn't appear with the leading space, so I would say it wasn't correctly explained.
Yes, LTRIM removes leading spaces but for REPLACE you'll need to remove the extra space.
Anyway, the author didn't come with a feedback yet, so all we can do is guessing.
Mark WillsTopic AdvisorCommented:
Hi motioneye,

Is there anything else we can do for you ?
motioneyeAuthor Commented:
Hi Guys,
This is fine, I manage to work on it by  "STUFF" Its really works with my needs.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.