Search notes:

SQL Server function: suser_sname

suser_sname returns the login name associated with a security identification number (SID).
When called without the optional parameter, it returns the name of the current security context.
select suser_sname()
TQ84_DMN\Rene
The SID of sa is 0x01:
select suser_sname(0x01)
sa
Querying database owners:
select
   suser_sname(owner_sid) database_owner,
   name                   database_name, 
   state_desc        , -- Online?
   owner_sid
from
   sys.databases

Misc

Because suser_sid() (without arguments) returns the SID of the current securty context, suser_sname(suser_sid()) is (always?) equal to suser_sname().

See also

Compare with suser_name()

Index