My Original_login() is a windows account. use [master] select orginal_login() Return:TFHGFHG-2005C97Administrator select user_name() Return:dbo But following code returns nothing in MASTER database: --------------------------------------------------------------------------------------------- SELECT a.name,b.name AS Login_Mapped_to_DBO FROM sys.database_principals a INNER JOIN sys.server_principals b ON a.sid = b.sid --------------------------------------------------------------------------------------------- But it can return a row when I run it in a user-created database: Return: dbo TFHGFHG-2005C97Administrator How can I translate a original_login() to a db user name? Thanks for any help.
Which version of SQL Server are you using? There is no such function called orginal_login() See who owns master dbsp_helpdb master
There is a function http://msdn.microsoft.com/en-us/library/ms189492.aspx and see this http://dinesql.blogspot.com/2009/10/username-susername-originallogin.html blog post to obtain the informaton.
[quote user="satya"] There is a function http://msdn.microsoft.com/en-us/library/ms189492.aspx and see this http://dinesql.blogspot.com/2009/10/username-susername-originallogin.html blog post to obtain the informaton. [/quote] Thanks. I didn't realise that I was using 2000 version when I tested it []
Even I was thinking for a second that there isn't such function in SQL, but our good old friend BOL gave me a kick to learn about this option.... learn new things everyday [].