title: How to find out user name and machine name to access to SQL server
body: <p>My work company has a MSSQL server 2005. I have two questions about finding out current log user and any way to send out a warning message:</p>
  
  <p>First question is if there is any T-SQL or SP available to find out current login user name and machine name. If the user is using SQL server sa name to remotely access to SQL server, is there any way to find out that user's windows name (the name to log to the windows)?</p>
  
  <p>My next question is that if I can get the user name or id, is there any way to send out a warning message such as "currently SQL server is clean up or backup, please do not log in at this time". I guess it may be difficult. I may have to send an email out to the user.</p>
  
  <p>The SQL server is only accessible in the company. The SQL server has a list of users as login users: windows users, SQL users and sa.</p>