Two of the parameters in SQL Server connections are the Application Name and the Host Name. You can see these in SQL Server if you execute the following command:
I've always been a fan of having applications identify themselves in their connection strings. It makes tasks like tracing much easier. The tools supplied with SQL Server do a reasonable job of that as you can see above. But many other tools don't do such a good job.
I was working at a site today where they are using Powershell to execute commands for monitoring. I noticed that the Powershell commands did not set the Application Name in the connection string when using Invoke-Sqlcmd. Note the following example:
I then tried to work out how to set the Application Name. When I checked the documentation for Invoke-Sqlcmd, it shows that the Hostname is set via the SQLCMD option –H, by using the –Hostname parameter.
However, note that if you use the –Hostname option, it actually sets the Application Name and does not set the Host Name:
While they're fixing this, it would be good to also add Application Intent as an option.
Don't forget to create the Connect article and add a link here so we can all upvote it.
It's already there:
https://connect.microsoft.com/PowerShell/feedback/details/1190033/hostname-parameter-for-invoke-sqlcmd-sets-the-application-name-not-the-host-name
upvoted – now we are 2 ! come on people – don't sit at the back grumbling that stuff doesn't get fixed, show you care (takes all of 10 seconds) and upvote your pet peeves on connect. Did anyone say JSON support ?
Now it's 6 of us!