Microsoft Dynamics NAV: Application Server from the Command Line
The NAV Application Server is (NAS) is a middle-tier server that executes NAV business logic (code) without user intervention. The NAS operates as an unattended client that is connected to the database server and runs as a service on a computer. One benefit of the NAS is that if it loses communication with the database server due to connection or server issues it does not stop, instead it will continue to attempt a connection to the database server.
When you install a NAS the setup will prompt you for the parameter information to use for connecting and communicating with the database server. This makes for an easy installation; however you may need to run more than one NAS on a computer. In this case you will need to install the NAS from the command line.
In the Application Server directory there are two executable files for launching the NAS; nas.exe and nassql.exe. To install the application server you can enter the following at the command line (example is for SQL Server) and substituting your values where appropriate:
nassql appservername=<appserver service name>, servername=<SQL Server/instance>,database=<database name>,Company="<Company Name>",startupparameter=<parameter to pass>,installasservice
To uninstall as NAS from the command line enter the following command:
nassql uninstallasservice, appservername=<appserver service name>
SQL: Long Running Transaction
For various reasons a SQL transaction can take an amount of time to complete. OPENTRAN is the Databas Console Command (DBCC) that can be used to display information about the oldest active transaction. The TABLERESULTS argument will display the results in a table format.
DBCC OPENTRAN WITH TABLERESULTS, NO_INFOMSGS

The information in the table may be limited, however, once you identify the process ID (SPID) you can see the last statement sent from a client to the server with the INPUTBUFFER command.
DBCC INPUTBUFFER (64)

SSIS: Programmatically set Flat File Destination filename
Recently, I was asked to export a subset of records to uniquely named delimited files. A task easily accomplished with SSIS by using a DataFlow Task and a Flat File Destination. In this case, however, I was required to export record groups based upon a shared sequence id. I was required to create a separate delimited file with a distinct name for each group. Within a Foreach Loop, which was used to loop through a set of sequence id to apply as a filter against the recordset, I added a Script Task to build the file name and set it to a string variable:
public void Main()
{
// this should be wrapped to catch errors
Dts.Variables["strFilename"].Value =
Dts.Variables["Sequence"].Value.ToString()
+ ".txt";
Dts.TaskResult = (int)ScriptResults.Success;
}
In the DataFlow Task I added a Flat File Destination and went through the steps of the wizard to add a [delimited] text file connection. I entered a generic name in for the filename. Once completed, the text file connection appeared in the Connection Manager Window. Select the text file connection, do not double click, which was created and look at the ConnectionString property in the Porperty Window. This is where the filename is stored. To change the filename programmatically you will need to create an expression for the text file connection. Click the ellipse next to the Expression property and choose ConnectionString as the property and enter the variable name, which was set in the Script Task, as the expression.
