SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


How to Delete Right 3 Characters from a string


How to Delete Right 3 Characters from a string

Author
Message
Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67561 Visits: 9671
Jeff Moden (7/22/2011)
Gah... I've got to learn to read the rest of the posts first. Tow other folks basically said the same thing.



I would point out the obvious that there's a reason you're #1 non employee-poster. But that's been said already Hehe.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)

Group: General Forum Members
Points: 215198 Visits: 41979
Ninja's_RGR'us (7/22/2011)
Jeff Moden (7/22/2011)
Gah... I've got to learn to read the rest of the posts first. Tow other folks basically said the same thing.



I would point out the obvious that there's a reason you're #1 non employee-poster. But that's been said already Hehe.


BWHAA-HAAA!!!! And the pot calls the kettle black. ;-)

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67561 Visits: 9671
Jeff Moden (7/23/2011)
Ninja's_RGR'us (7/22/2011)
Jeff Moden (7/22/2011)
Gah... I've got to learn to read the rest of the posts first. Tow other folks basically said the same thing.



I would point out the obvious that there's a reason you're #1 non employee-poster. But that's been said already Hehe.


BWHAA-HAAA!!!! And the pot calls the kettle black. ;-)


Here you go, 3 free points. Tx for closing my case :-D.
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)

Group: General Forum Members
Points: 215198 Visits: 41979
Ya know, Remi... I thought you were just joking.

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67561 Visits: 9671
Jeff Moden (7/23/2011)
Ya know, Remi... I thought you were just joking.



Of course I am. Why would you think otherwise ;-).
andrew.sugden
andrew.sugden
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 14
Fair enuff. In the scenario I was using it I wanted to get rid of 3 letters that had been added to a file number e.g
CaseCode: 1017856AVN.
In database wanted to link it to the file number & file type were in separate columns i.e.
Case number: 1017856 Case type: AVN
So to get CaseCode in 1st DB to match Case number in 2nd DB Kingston's REPLACE worked fine.
Ninja's_RGR'us
Ninja's_RGR'us
SSC Guru
SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)SSC Guru (67K reputation)

Group: General Forum Members
Points: 67561 Visits: 9671
andrew.sugden (7/24/2011)
Fair enuff. In the scenario I was using it I wanted to get rid of 3 letters that had been added to a file number e.g
CaseCode: 1017856AVN.
In database wanted to link it to the file number & file type were in separate columns i.e.
Case number: 1017856 Case type: AVN
So to get CaseCode in 1st DB to match Case number in 2nd DB Kingston's REPLACE worked fine.




All we said is that it can delete the wrong data with replace. Left is clear as day. Whack the last 3 characters and most importantly, it cannot fail.
andrew.sugden
andrew.sugden
Valued Member
Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)Valued Member (57 reputation)

Group: General Forum Members
Points: 57 Visits: 14
I know. That's why said fair enuff.
Kingston Dhasian
Kingston Dhasian
SSCertifiable
SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)SSCertifiable (6K reputation)

Group: General Forum Members
Points: 6028 Visits: 5280
Jeff Moden (7/22/2011)
Sugsy (7/22/2011)
Just for the record Kingston's suggestion works fine n'all


Just for the record, it will also delete the wrong data if the right 3 occurs more than once in the string. Don't use it. ;-)

(Sorry, Kingston)


This post is more than a year and a half old. When I saw it today, I was like "Why did i post that?". I will not give a similar reply today for sure. I hope I am more mature now and I am not a quick fix developer anymore who gives quick fixes which can prove nasty, thanks mainly to people like you in SQL Sever Central.

And Jeff, I also remember you giving me firing for giving a similar sort of quick fix earlier. I didn't feel bad a single bit even that day. Keep them coming. I would love to be corrected.

Once again, thanks Jeff.


Kingston Dhasian

How to post data/code on a forum to get the best help - Jeff Moden
http://www.sqlservercentral.com/articles/Best+Practices/61537/
Jeff Moden
Jeff Moden
SSC Guru
SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)SSC Guru (215K reputation)

Group: General Forum Members
Points: 215198 Visits: 41979
Kingston, you're the consumate gentleman and a dedicated programmer. I'd work with anytime. Thank you for the feedback. :-)

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search