2

Can anyone explain the how below mentioned query detect program_name eg: Microsoft SQL Server Management Studio,Microsoft SQL Server Management Studio - Query etc..

select login_name,program_name,host_name,nt_domain,nt_user_name from sys.dm_exec_sessions 
5
  • The application passes that value when it connects to the server. Commented Jun 24, 2014 at 11:35
  • if I create my own application and want to connect it with SQL with its own application name which will be maintained in SQL session. Actually I am just wondering if I connect ms excel or any other application with sql it detects application name,and it is not automatically getting done. there must be a parameter to pass. Commented Jun 24, 2014 at 11:41
  • I just know how to do that using Java/JDBC. But other programming languages should have similar features. Commented Jun 24, 2014 at 11:43
  • Ok. can you please share the code. I want to implement this in C# but java code may help. Commented Jun 24, 2014 at 11:45
  • 1
    I just pass connection properties as documented here: msdn.microsoft.com/en-us/library/ms378988%28v=sql.110%29.aspx Commented Jun 24, 2014 at 11:50

1 Answer 1

8

SQL Server detect program name from connection string property.

You can change your program name of your SSMS by used following step.

Step 1

enter image description here

After connect to your database you can get following query :

Select login_name,
       program_name,
       host_name,
       nt_domain,
       nt_user_name 
From sys.dm_exec_sessions

You can also use connection string parameter from your application.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.