Options

How do I find the SQL Server Version through Nav Client code

mcoAggiemcoAggie Member Posts: 23
Does anyone know an easy method to find the SQL Server version from within the Nav client?

I want to find out which db versions our clients are on because this is going to become more of an issue. I would like to be able to do this without knowing another connection string or at least use the same one as finsql.exe is using.

Comments

  • ArhontisArhontis Member Posts: 667
    edited 2006-11-09
    Hi,

    @version' which returns a string which includes the version of the sql server.

    There is info in the net that tell you which version any version code actually is.

    I include a code sample:
    autSQLServer	Automation	'Microsoft SQLDMO Object Library'.SQLServer	
    res	Automation	'Microsoft SQLDMO Object Library'.QueryResults	
    autDatabases	Automation	'Microsoft SQLDMO Object Library'.Databases	
    autDB	Automation	'Microsoft SQLDMO Object Library'.Database	
    
    //connect to server
    CREATE(autSQLServer);
    autSQLServer.Connect(ServerName, Username, Password);
    
    //find the desired database in the collection
    autDatabases := autSQLServer.Databases;
    i:=1;
    Found := FALSE;
    WHILE (i <= autDatabases.Count) AND (NOT Found) DO BEGIN
      autDB := autDatabases.ItemByID(i);
      DBName := autDB.Name;
      IF DBName = 'master' THEN
        Found := TRUE;
      i:=i+1;
    END;
    
    //execute a query
    res:=autDB.ExecuteWithResults('select @@version');
    MESSAGE(res.GetColumnString(1,1));
    
    //disconnect from the server and clear all vars
    autSQLServer.DisConnect;
    autSQLServer.Close;
    CLEARALL;
    

    This is some code I have written some time ago for test...
  • ArhontisArhontis Member Posts: 667
    Additionaly you could get the server name which you are connected by using the server record and filter with "My Server" TRUE.

    You can find better sql statements and info about the actual sql server versions here:
    http://support.microsoft.com/kb/321185
  • mcoAggiemcoAggie Member Posts: 23
    Thanks Arhonits,

    This helps.

    I wanted to give a way for our help desk to update our CRM info without too much trouble. It would be nice if there was a virtual table that stored the connection information.

    I may just write something to check the servers and the authorization mode and allow the user to update the connection on the request form.
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Can't you just call the function in CU 1?
    David Singleton
  • ara3nara3n Member Posts: 9,258
    Can't you just call the function in CU 1?

    Could you explain?
    Ahmed Rashed Amini
    Independent Consultant/Developer


    blog: https://dynamicsuser.net/nav/b/ara3n
  • David_SingletonDavid_Singleton Member Posts: 5,479
    Can't you just call the function in CU 1?

    Please ignore this, I miss read the question :oops:
    David Singleton
Sign In or Register to comment.