T-SQL: SUSER_SNAME vs SUSER_NAME?

If you call the function without an argument they will both return the same value. But they do take different arguments:

  • SUSER_SNAME() takes the varbinary(85) SID of a login as argument
  • SUSER_NAME() takes the integer principal_id of a login

You can verify this like:

select  suser_name(principal_id)
,       suser_name(sid)
,       suser_sname(principal_id)
,       suser_sname(sid)
from    sys.server_principals 
where   name = suser_name()

Only the first and last column will return non-null values.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)