devxlogo

Return the Program Name for the Current Session in SQL Server

Return the Program Name for the Current Session in SQL Server

SQL Server 6.5 has an APP_NAME() function which returns the program name for the current session. This function is useful for tracking which client applications are running processes in SQL Server or for limiting access to specific applications. This built-in function returns the program name for the current session if the program has set one. The value returned must have a char or varchar datatype and can be a maximum length of 30 characters. This example checks that the client application that initiated this process is the correct one:

 DECLARE @ThisApp varchar(30)SELECT @ThisApp = APP_NAME()IF @ThisApp <> 'App3'LogPRINT "This process was not started with the current version of the Log program"
See also  Professionalism Starts in Your Inbox: Keys to Presenting Your Best Self in Email
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist