Dynamics NAV: Get Database Name for current installation

I started writing a couple blogs to determine, if the current installation is a multitenant installation or how to get the name of the current SQL Server. There are a few more useful things that you can do with the DLLS that are shipped with Dynamics NAV. I am going to add some more with different blog posts and hope that you will find them useful and don’t have to spend as much time as I needed until I found this. You might also look a bit more into this DLL, since you have access to all of the configuration settings that you have in the NAV Administration Console or the actual .config file.

I have tested this with NAV versions 2013 R2 and higher, it works in all versions. There are slight differences in the different versions, since you will have to reference the proper DLL for your version. The “Version=” part of the DLL listed below must be replaced with the following for each version.

NAV Version Version=
2013 R2

I wrapped this is a function shown below. The function declares the following local variable:

Name: ServerUserSettings
Type: DotNet
Subtype: Microsoft.Dynamics.Nav.Types.ServerUserSettings.’Microsoft.Dynamics.Nav.Types, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35′

GetDatabaseName() : Text
ServerUserSettings := ServerUserSettings.Instance();

The first line instantiates the .NET variable, which is one of the DLLs that Microsoft ships with Dynamics NAV. And the next line returns the database name. Very easy, isn’t it?


    • Paolo Titta on April 30, 2018 at 5:52 am
    • Reply

    Hello it seems not works anymore in NAV 2018… The Dll changed?
    There is another way to obtain the name of the instance?

    • Carsten on February 13, 2019 at 9:33 am
    • Reply

    Hi Paolo,
    If you miss the DLL you can just copy it from the Roletailored Client Path in the Add-ins Path. Then you can find it in the overview.

    Best regards

Leave a Reply to Paolo Titta Cancel reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.