My Assistant
![]() ![]() |
|
|
May 4 2012, 10:15 PM
Post
#1
|
|
|
UtterAccess Member Posts: 30 |
I have misjudged the size of the digits I need for my primary key, and now I found I need to add more. My previous primary keys look like: P-000001, P-000002, and so on. However, now, it is approaching P-999999! I have the intention to add new digits to P-000XXXXXX. However, I need to keep the previous data with the new format.
I have attempted to use this query: Update tblReturC Set Nomor = "P-000*" Where Nomor Like "P-*" But it does not want to do it properly. Is there any better ways to do it? Thanks. |
|
|
|
May 4 2012, 10:28 PM
Post
#2
|
|
|
Access Wiki and Forums Moderator Posts: 48,113 From: SoCal, USA |
Hi,
You could try something like: UPDATE tblReturC SET Nomor = Replace(Nomor, "P-", "P-000") Just my 2 cents... (IMG:style_emoticons/default/2cents.gif) |
|
|
|
May 4 2012, 11:12 PM
Post
#3
|
|
|
UtterAccess VIP Posts: 2,550 From: Parma, Idaho, US |
I presume this primary key is related to foreign keys in other tables? If so you should be sure that you have relationships with referential integrity enforced, and check the "CASCADE UPDATES" checkbox in the relationships window for all the relationships (including "grandchild" relationships, if there are any).
The Replace() function should work; for an alternative you could update it to Left([NOMOR], 2) & "000" & Mid([NOMOR], 3) Whichever way you do it back up the database first! |
|
|
|
May 4 2012, 11:38 PM
Post
#4
|
|
|
UtterAccess Member Posts: 30 |
OK, guys. that works splendidly. And thank you for the advices too. Much appreciated.
|
|
|
|
May 5 2012, 11:16 AM
Post
#5
|
|
|
Access Wiki and Forums Moderator Posts: 48,113 From: SoCal, USA |
|
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 25th May 2013 - 06:08 AM |