October 7, 2005 at 11:59 am
I have a table with account info like:
ACCT_ID
10000-01
BT000-02
ACBD0-13
I need to insert a 3 after each dash, to look like:
10000-301
BT000-302
ACBD0-313
What would be the proper command to do this?
Thanks in advance.
October 7, 2005 at 12:03 pm
UPDATE dbo.YourTableName SET FieldName = REPLACE (FieldName, '-', '-3')
October 7, 2005 at 12:08 pm
Thanks, worked great!
October 7, 2005 at 12:23 pm
HTH.
October 7, 2005 at 1:09 pm
If this is not going to be a one shot pony make sure that the UPDATE doesn't update records that are already -3....
Good Hunting!
AJ Ahrens
webmaster@kritter.net
October 7, 2005 at 1:15 pm
Since we're making valid points >>
update... where charindex ('-', FieldName, 1) > 0 so that you update only the rows that need changing.
October 7, 2005 at 1:49 pm
and if we get really picky:>>>
update... where FieldName Like '_____-%'
* Noel
October 7, 2005 at 1:52 pm
Now you're assuming that the field is indexed .
October 7, 2005 at 1:56 pm
Yeah sometimes I like to guess a bit
* Noel
November 2, 2005 at 12:10 pm
This helped me. Thanks!
Viewing 10 posts - 1 through 9 (of 9 total)
You must be logged in to reply to this topic. Login to reply