I've got a stored procedure which runs this to create a new ticket number:
INSERT INTO [Test_DB42].[dbo].[TicketNumber]
([On], [By])
VALUES (CURRENT_TIMESTAMP, CURRENT_USER)
When I run with a user with db_datareader and execute permissions, I get the Active Directory samAccountName value which is what I want - this user gets access via an AD group which has a Login.
When I run with a user with sysadmin role it just says 'dbo'. This use has an explicit Login for their AD account.
Is there anyway to change this, or to return the AD samAccountName or SQL Login name?
Use SUSER_SNAME()
instead of CURRENT_USER
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With