How to rename a primary key

mustafaAlsoufi
Member Posts: 66
I'm trying to rename a primary key in a table by creating a new batch report. For instance, the original name of the first Entry No. is 10, I want to make it 1.
Can anyone help me how to achieve that?
Thanks in advance.
Can anyone help me how to achieve that?
Thanks in advance.
0
Best Answer
-
1. Create a holding table for the data. This should be a copy of the original table. It can be a temporary or real table.
2. Copy the records to this holding table while deleting from the real table.
3. Copy back to real table and update the primary key values before inserting,
There are no bugs - only undocumented features.0
Answers
-
1. Create a holding table for the data. This should be a copy of the original table. It can be a temporary or real table.
2. Copy the records to this holding table while deleting from the real table.
3. Copy back to real table and update the primary key values before inserting,
There are no bugs - only undocumented features.0 -
Take care with relations! E.g. the G/L entry PK is also stored in the "G/L Entry - VAT Entry Link" table, so you will also have to change all entry numbers in related tables0
-
That's what rec.RENAME is for.0
-
Rec.Rename is fine when renaming a single (or a few) records. It is very inefficient when the need is to rename a large number of records.
As mentioned above, you do need to pay attention to any table relations.There are no bugs - only undocumented features.0 -
Thank you all for your answers. Much Appreciated0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions