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 Posts: 18
    Accepted 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 Posts: 117Member
    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 Posts: 18Member
    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 Posts: 3Member
    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 Posts: 18Member
    Accepted 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 Posts: 3Member
    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 Posts: 18Member
    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 Posts: 8,796Member, Moderator
    [Topic moved from 'NAV/Navision Classic Client' forum to 'NAV Three Tier' forum]

    Regards,Alain Krikilion
    Use the SEARCH,Luke! || No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
    NAV TechDays 2019: 21 & 22 November 2019, Antwerp (Belgium)
Sign In or Register to comment.