Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Tuesday, December 2, 2014 8:21 PM
Hi,
We are passing Application Name dynamically from the connection string (.net) and using it in SQL 2008 trigger using PROGRAM_NAME() from sys.dm_exec_sessions. Most of the time we get the desired result but sometimes it returns ".Net SqlClient Data Provider".
Please suggest is there any issue in using sys.dm_exec_sessions. We are using following query to get application name in trigger.
"select top 1 program_name from sys.dm_exec_sessions"
Should we use APP_NAME instead?
Please help.
Tuesday, December 2, 2014 11:28 PM ✅Answered
app_name() is certainly better as it does not require any permissions. And if the user has permissions enough, the dm_exec query could return the application name for someone elses application.
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se