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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/developm...', 1740449214, '3.133.160.104', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/development/databases/SQL-Server/T-SQL/functions/security/suser_sname(63): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78