In SQL Server, you can use the APP_NAME()
function to get the application name for the current session. This assumes the application sets that name value.
You can use this function to distinguish between different applications, as a way to perform different actions for those applications.
Note that the client provides the application name, and so the result returned by this function simply reflects whatever name the client provides. For this reason, Microsoft advises that this function should not be used for security checks.