Compiling Table

FinSQLPath := ‘“C:\Program Files (x86)\Microsoft Dynamics NAV\71\RoleTailored Client\finsql.exe”’;
ServerName := ‘“newserver.newdomain.com:5097/test_live_150218”’;
DatabaseName := ‘TEST_LIVE_150218’;
Filter := ‘“Type=Table;ID=5406”’;

Command := FinSQLPath + ’ command=compileobjects,servername=’ + ServerName + ‘,database=’ + DatabaseName + ‘,filter=’ + Filter;

ExecuteBat := ExecuteBat.ProcessStartInfo(‘cmd’, ‘/c "’ + Command + ‘"’); //Provide Details of the Process that need to be Executed.
ExecuteBat.RedirectStandardError := TRUE; // In Case of Error the Error Should be Redirected.
ExecuteBat.RedirectStandardOutput := TRUE; // In Case of Sucess the Error Should be Redirected.
ExecuteBat.UseShellExecute := FALSE;
ExecuteBat.CreateNoWindow := TRUE; // In case we want to see the window set it to False.
Process := Process.Process; // Constructor
Process.StartInfo(ExecuteBat);
Process.Start;
ErrorMsg := Process.StandardError.ReadToEnd(); // Check Error Exist or Not
IF ErrorMsg <> ‘’ THEN
ERROR(’%1’,ErrorMsg)
ELSE BEGIN
Result := Process.StandardOutput.ReadToEnd();// Display the Query in the Batch File.
MESSAGE(’%1’,Result);
END;

Look if have written something wrong.

pastedimage1521633763435v1.png

Servername is wrong… it must be database server name, in this case “NEWSERVER”. Additionally, you can remove the result message, it never will show anything.

I have tried by changing the database name but no error occurs.