Home Forums SQL Server 2005 Administering GET the windows or Operating System loginname using sql server 2005 RE: GET the windows or Operating System loginname using sql server 2005

  • You are getting confused here about security context. When you log into SQL Server as "sa", SQL Server is a self-contained system. It has no knowledge, or even rights, to query your workstation. The only thing SQL Server has, and it can be changed, is the information that the driver sends. By default that's an app name, a workstation, etc. However those aren't necessarily correct. They can be overridden by someone making the connection.

    While it's possible that you could make some query to get the workstation name, if you are using SQL authentication, SQL Server has no way to query on your behalf. Even an xp_cmdshell type query runs under the server context, so it can't go back and determine the logged in user.

    Can I ask what you are trying to do?