Question : Get Terminal Server Client Name via T-SQL

I have a SQL Server application running on a citrix platform I need to know the client machine name in SQL Server,

i tried using the statement:

xp_cmdshell 'ECHO %CLIENTNAME%' and it returns null, strangely when I run this command in the cmd window i do get the desired value

when i run the SET command it lists me all the environment values but clientname is not there amongst other values, when i run it in the commant prompt window i do see more values including the clientname.

I'm open to any other suggestion how to get the client name

Thanks

Answer : Get Terminal Server Client Name via T-SQL

All the extended stored procedures in SQL server are executed on the hosting machine where SQL server resides. Remember, applications talk to the SQL server through connections by sending commands to that machine and getting back responses from it. There are 2 different environments we are talking about here unless the application is actually on the same machine with the SQL server, which usually isn't.

If you need to store the client's name in the SQL database then you need to find that name from the application that runs on the client and then pass it as a parameter to the SQL database and store it. You cannot do that using any SQL statement but for sure you can do it from your application. You only need to find the right function or system variable call that returns that.
Random Solutions  
 
programming4us programming4us