Follow sqlserver-dba.com

Subscribe to RSS feed  Follow @jackvamvas - Twitter

*Use the Comments section for questions

SQLServer-DBA.com Links

Dba_db2_button

dba-ninja.com

SQL Server DBA Jobs

select current_user shows dbo

14 June,2018 by Tom Collins

Question: I'm logged onto a SQL Server 2016 instance  using Windows Authentication and executing SELECT CURRENT_USER. Although I have sysadmin rights - the result always returns dbo.  

What I need is to return my domain account name. Can you help?

Answer: There is a difference between CURRENT_USER and SYSTEM_USER. 

SELECT CURRENT_USER  - Returns the name of the current user. This function is equivalent to SELECT USER_NAME().  

If the current user is a sysadmin privilege , the recordset returns “dbo”, rather than the logon name. Which because your current logon has sysadmin privileges explains the dbo result

SELECT SYSTEM_USER (also synonym for SUSER_SNAME().  -  Returns the login name associated with a security identification number. SELECT SYSTEM_USER will return your domain name

 

 

 

 

 

 

 

 


Author: Tom Collins (http://www.sqlserver-dba.com)


Share:

Verify your Comment

Previewing your Comment

This is only a preview. Your comment has not yet been posted.

Working...
Your comment could not be posted. Error type:
Your comment has been posted. Post another comment

The letters and numbers you entered did not match the image. Please try again.

As a final step before posting your comment, enter the letters and numbers you see in the image below. This prevents automated programs from posting comments.

Having trouble reading this image? View an alternate.

Working...

Post a comment on select current_user shows dbo


sqlserver-dba.com | SQL Server Performance Tuning | SQL Server DBA:Everything | FAQ | Contact|Copyright & Disclaimer