Returns the application name for the current session if one has been set by the application.
APP_NAME()
nvarchar(128)
This example checks whether the client application that initiated this process is a SQL Server Query Analyzer session.
DECLARE @CurrentApp varchar(35)
SET @CurrentApp = APP_NAME()
IF @CurrentApp <> 'MS SQL Server Query Analyzer'
PRINT 'This process was not started by a SQL Server Query Analyzer query session.'