Skip to content
Advertisement

How to find login name in SQL Server from a user_name of database

How can I find login name in SQL Server from a user_name of database using a stored procedure?

Advertisement

Answer

For example you can use the system functions

declare @uname sysname = 'dbo'; -- user name in question
SELECT suser_sname(user_sid(USER_ID(@uname))) as login

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement