How do we delete a table completely from a database?

I have a table containing some records, and this table need to be remove completely from the database. How can I do so?

Best Answer

  • JP_BagdonasJP_Bagdonas Member Posts: 18
    Answer ✓
    "Then I need to copy all the existing data from Table A to Table B"
    For this use TRANSFERFIELDS if table B is a copy of A. Otherwise copy all values individually.

    Jimmy if you dont explain in details what you need it will be hard to help you :(
    Make one simple example like TableA.No, TableA."Line No." then copy to TableB.Code, etc....

Answers

  • navisionerinnavisionerin Member Posts: 161
    you can delete it from the development environment or sql but wouldnt recooment it unless is custom table. Otherwise it might contain functions used by reports/pages/condeunits which you would need in general!
  • JP_BagdonasJP_Bagdonas Member Posts: 18
    using your test database, you could delete the table from object designer, then compile all objects to detect if any relationship was broken after deleting the table.
  • jimmyliew1997jimmyliew1997 Member Posts: 3
    I am sorry I did not fully put in what I am asking for. I meant to do it via AL Coding in Visual Studio Code instead of Dynamic Development Environment. What I need is, from Table A, I added a new field call newField. Then I need to copy all the existing data from Table A to Table B in order to change the primary key and fill the data in to the newField automatically as well.

    Take note that: The newField is the new primary key.
  • JP_BagdonasJP_Bagdonas Member Posts: 18
    Answer ✓
    "Then I need to copy all the existing data from Table A to Table B"
    For this use TRANSFERFIELDS if table B is a copy of A. Otherwise copy all values individually.

    Jimmy if you dont explain in details what you need it will be hard to help you :(
    Make one simple example like TableA.No, TableA."Line No." then copy to TableB.Code, etc....
  • jimmyliew1997jimmyliew1997 Member Posts: 3
    After that, can I know how do we delete the Table A? Since Table B is now permanent in the database and will using and Table A will not be using anymore.
  • JP_BagdonasJP_Bagdonas Member Posts: 18
    ahhhh now I know what you want to achieve :smiley:
    that is tricky indeed !!!

    the answer is on the launch.json file
    19ueotmcpvob.png

    when you use the Recreate option it will erase all data for all tables used for your extension
    if you are in development phase, lucky you, just rebuild all

    but seems like you have a live scenario, where you want to copy all data to different tables, and then rebuild solution and move data back to original tables.

    if you need my help i might be able to help you, skype me joao.bagdonas
  • krikikriki Member, Moderator Posts: 9,115
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    No PM,please use the forum. || May the <SOLVED>-attribute be in your title!


Sign In or Register to comment.