SQL: Developers – Please add an Application Name to your SQL Server connection strings !

A pet dislike of mine is application developers creating connection strings, but without Application Names. That's painful because when  you view the processes in SQL Server Activity Monitor, or look at commands in traces from SQL Server Profiler or Extended Events Profiler, you see this:

If your connection just says .Net SqlClient Data Provider, no-one has any idea what application that is. If you are using another connection library, it might say a different name but the concept is the same. You are making management of the server much harder than it needs to be.

So what I want you to do instead, is to just specify Application Name=GregsAwesomeApp in your connection string, so that we see this:

Way better! Now we know which applications are associated with which connections. In that screenshot, you can also see that Microsoft has also been better lately in making sure all their applications have names.

OK, so now you say "what if someone renames the application?" To get around that, if you're a real star, consider dynamically retrieving the name of the running application, and adding that to the connection string as the application name. Either way, please set a meaningful value there to make it easier for the people managing the database server.

You'll also be way better off when you need to filter Profiler or Extended Events Profiler traces.

 

Leave a Reply

Your email address will not be published.