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