APP_NAME Built-in Function (version 6.5)

Returns the program name for the current session. This function is useful for tracking which client applications are running processes in SQL Server or to limit access to specific applications.

Syntax

APP_NAME()

Remarks

This built-in function returns the program name for the current session if one has been set by the program.

Note The value returned must have a char or varchar datatype and can be a maximum length of 30 characters.

Example

This example checks that the client application that initiated this process is the correct one.

DECLARE @ThisApp varchar(35)
SELECT @ThisApp = APP_NAME()
IF @ThisApp <> 'Log3'
PRINT "This process was not started with the current 
version of the Log program"