Find the Primary Keys of NAV Tables

ChinmoyChinmoy Member Posts: 359
edited 2012-10-26 in NAV Three Tier
Hi,

I was trying to find out the keys of some tables of NAV (native Db). I did it with the following code in a report / form and populated a table with the keys:

RecRef RecordRef
i Integer
Keys Text 250
ObjectList Record Object List
ValidateTable Record Field

FOR i := 1000000 to 10009999 DO
//Just a specified range of tables
BEGIN
ValidateTable.RESET;
ValidateTable.SETRANGE(TableNo,i);
IF ValidateTable.FINDFIRST THEN
BEGIN
RecRef.OPEN(i);
Keys := '';
Keys := RecRef.CURRENTKEY();
IF Keys <> '' THEN
BEGIN
ObjectList.INIT;
ObjectList."Object No." := i;
ObjectList."Object Caption" := Keys;
ObjectList.INSERT;
END;
RecRef.CLOSE;
END;
END;

Note: I cannot take a backup of the db and restore on SQL server. I only have access to the NAV db with limited administrative permissions

Is there any other better way to do this?

Kind regards,

Chn

Answers

  • einsTeIn.NETeinsTeIn.NET Member Posts: 1,050
    Take a look at Table 2000000063 Key.
    "Money is likewise the greatest chance and the greatest scourge of mankind."
  • ChinmoyChinmoy Member Posts: 359
    Good one. I guess the clustered indexes are the ones which are the primary keys.

    Thanks!

    Chn
  • strykstryk Member Posts: 645
    Chinmoy wrote:
    I guess the clustered indexes are the ones which are the primary keys.
    Not necessarily. Keys and Indexes are handled differently. But indeed, in most cases the PK is also flagged as "Clustered".
    Take a look at Table 2000000063 Key.

    Exactly. Just filter on "Key ID" = 1 :thumbsup:
    Jörg A. Stryk (MVP - Dynamics NAV)
    NAV/SQL Performance Optimization & Troubleshooting
    STRYK System Improvement
    The Blog - The Book - The Tool
  • ChinmoyChinmoy Member Posts: 359
    Thanks again! This is working as expected.

    :thumbsup:

    Chn
Sign In or Register to comment.