When a connection is made to SQL Server there are by default no way for SQL Server to know what software is making the connection.

If several apps are using a shared SQL Server and there are problems caused by a certain connection, the database administrators will be able to locate that connection by something called a SPID. However determining what application or website is responsible for the connection causing the error is harder.

But if the developer includes the "Application Name" property in the connection string then it will be very easy for the database administrator to see the name of the application that is causing the trouble. This will save hours for the DBA and it will make the developer popular amongst the DBAs.

How?

Simply include "Application Name=MyAppName;" in the connection string. After that it is also possible to use that value in SQL batches or SPROCs with the command, "SELECT APP_NAME();".

Summary

Always Include the optional Application Name parameter in your connection strings when connecting to SQL Server. This way the SQL Server will have info on what application is using the connection. This can be invaluable info when locating errors in the database server.

Articlesread all

Connect

Not what you were looking for?

Browse the other articles in the knowledge base!

Or search kb articles, Q&A content and every connection string here.

Start over in the connection string reference or check out the Q&A forums where you can ask your own questions!