Whats the difference between
asked Oct 21 '11 at 06:14 AM in Default
The difference is in the arguments that those functions take.
SUSER_SNAME(), takes an optional varbinary(85) argument, which is the security identification number of a SQL Server login / windows login / windows group. You can get your SID by executing
SUSER_NAME(), takes an optional integer argument, which is the login id of a SQL server login / windows user / windows group. You can get your login id by executing
Without arguments, they both return the current user.
Which one should you use - depends on what are you trying to do?