|
Whats the difference between
(comments are locked)
|
|
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? Ahhh, you beat me with 19seconds. :)
Oct 21 '11 at 06:37 AM
Håkan Winther
Well, I'm trying to find out who is executing my stored procedure! Is there a situation where SUSER_SNAME() and SUSER_NAME() return different results? Or can I mix them around im my code?
Oct 21 '11 at 06:44 AM
eghetto
I'm not aware of a situation where they can return different results, when called without arguments, even in impersonation contexts. I would just choose one and then stick with that one!
Oct 21 '11 at 07:00 AM
Kev Riley ♦♦
Thanks! That's fine to me!
Oct 21 '11 at 07:09 AM
eghetto
@Håkan - you shouldn't have deleted yours - you made a good point about a change in SQL 7 - provides a bit of background :)
Oct 21 '11 at 07:12 AM
Kev Riley ♦♦
(comments are locked)
|

