Can we modify the data type of a fields once data is entered

mkpjsr
Member Posts: 587
Hi all,
can we modify the data type of a field without deleting the records from the table.
I tried to do so but its giving an error. Whats the solution.
can we modify the data type of a field without deleting the records from the table.
I tried to do so but its giving an error. Whats the solution.
0
Comments
-
It depends on the type.
Usually you will need to create a temp field, copy the data into it, change the original field data type, then copy the data back (converting as necessary). Then delete the temp field.0 -
Think about that one. If you have a text field that contains a value 'test', could you change that to a numeric data type? If you have a code field with a length of 20, with a value 'VERYLONGCODEFIELD', could you change the datatype to Code10?
You can only change the data type when existing values are compatible. So you can change Text10 to Text20, because all values fit into the target data type. It doesn't work the other way around.
Which brings us to why you want to change. If you have existing data in the field, that must mean something, so you can't just go in and delete a whole bunch of values. You have to come up with a plan to convert values into the new data type. Don't try to just hack your way around and see where it ends. Think about it, write it up and design a solution that works.0 -
DenSter wrote:Think about that one. If you have a text field that contains a value 'test', could you change that to a numeric data type? If you have a code field with a length of 20, with a value 'VERYLONGCODEFIELD', could you change the datatype to Code10?
You can only change the data type when existing values are compatible. So you can change Text10 to Text20, because all values fit into the target data type. It doesn't work the other way around.
Which brings us to why you want to change. If you have existing data in the field, that must mean something, so you can't just go in and delete a whole bunch of values. You have to come up with a plan to convert values into the new data type. Don't try to just hack your way around and see where it ends. Think about it, write it up and design a solution that works.
Actually there is a table with some integer type fields and now i want to convert it to decimal but it not allowing me to do so. I think there should not be any compatibility issue when we convert from Integer to Decimal.0 -
Because these types are different (you can change only size of text from smaller to bigger, you cannot change the type) you need to export the data from this field to some temporary field, clear the original field, change the datatype and move the data from temp. field back to the retyped field...0
-
mkpjsr wrote:I think there should not be any compatibility issue when we convert from Integer to Decimal.0
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