Log in  ::  Register  ::  Not logged in

 Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Insert a character in a string Rate Topic Display Mode Topic Options
Author
 Message
 Posted Monday, July 30, 2012 10:37 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Wednesday, May 20, 2015 4:44 AM Points: 106, Visits: 365
 Good afternoon,I have part numbers that begin as RA99999-99. I need to update them all to read RA099999-99. Thanks for any help.
Post #1337392
 Posted Monday, July 30, 2012 10:40 AM
 SSCrazy Group: General Forum Members Last Login: Saturday, November 19, 2016 1:44 PM Points: 2,271, Visits: 5,545
 Will always the first two characters be alphabets ? and will it always be two characters?
Post #1337395
 Posted Monday, July 30, 2012 10:41 AM
 SSC Eights! Group: General Forum Members Last Login: Today @ 8:10 AM Points: 810, Visits: 6,577
 I think the STUFF function is what you are looking for.`declare @txt varchar(20) = 'RA99999-99'select STUFF(@txt, 3, 0, '0')`
Post #1337396
 Posted Monday, July 30, 2012 10:41 AM
 SSCrazy Group: General Forum Members Last Login: Saturday, November 19, 2016 1:44 PM Points: 2,271, Visits: 5,545
 Try`SELECT STUFF ('RA99999-09',3,0,'0')`
Post #1337398
 Posted Monday, July 30, 2012 10:51 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Wednesday, May 20, 2015 4:44 AM Points: 106, Visits: 365
 The first characters will always be letters.
Post #1337412
 Posted Monday, July 30, 2012 10:29 PM
 SSC-Forever Group: General Forum Members Last Login: Today @ 8:40 AM Points: 42,081, Visits: 39,472
 kabaari (7/30/2012)The first characters will always be letters.I guess the best way to ask the question is "Do you always want the extra "0" to be inserted into the 3rd character position?" If so, then the STUFF methods listed before this will do the job. If not, post back with some additional details. --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." Helpful Links:How to post code problemsHow to post performance problems
Post #1337659

 Permissions

 Copyright © 2002-2016 Redgate. All Rights Reserved. Privacy Policy. Terms of Use. Report Abuse.