Click here to monitor SSC
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-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20919 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-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44845 Visits: 39850
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

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

Group: General Forum Members
Points: 20919 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-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44845 Visits: 39850
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

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

Group: General Forum Members
Points: 20919 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
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 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-Insane
SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)SSC-Insane (20K reputation)

Group: General Forum Members
Points: 20919 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
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

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

Group: General Forum Members
Points: 2999 Visits: 4986
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-Forever
SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)SSC-Forever (44K reputation)

Group: General Forum Members
Points: 44845 Visits: 39850
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.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is usually not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

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