Working with SQL Server through .NET Interop

The Upgrade Toolkit objects that shipped with Microsoft Dynamics NAV 2013 have a good example of code that works directly with SQL Server through the .NET Framework library. On the product media, navigate to this location:

..\UpgradeToolKit\Data Conversion Tools\601\

Import the Upgrade 601700.2.fob file. This contains codeunit 104050 Upgrade - SQL Mgt.:

and codeunit 104049 Upgrade Dimension entry - SQL:


The same code structure should be applicable to Microsoft Dynamics NAV 2009 R2, though only for the RoleTailored client.


I hope this helps you create codeunits that connect to SQL Server through .NET Interop.


Best regards,

Alexey Finogenov

Comments (2)

  1. says:

    Also worth checking out – lets you populate any NAV temp table with results from SQL.

  2. Michael Kaluza says:

    Hello Alexey,

    thank you very much for this example. Can you tell me what I have to do, to find the Name of the SQL Server and SQL Server Instance by c/al code so I can connect with the SQL Server.

    The CU 104049 works only when the nst Service of the upgrade database is a main instance on the Server.

    Best regards


Skip to main content