Collections:
Finding the Login Name Linked to a Given User Name in SQL Server
How To Find the Login Name Linked to a Given User Name in SQL Server?
✍: FYIcenter.com
If you know a user name in a database and you want to find out which login name is linked this user name, you need to check the Security ID (SID) of the user name based on the following rules:
So the login name linked to a user name must have the SID as the user name. The tutorial exercise below shows you how to find the login name that is linked to the user name "Fyi_User":
-- Login with sa
USE FyiCenterData;
GO
SELECT u.name AS User_Name, l.name AS Login_Name, u.sid
FROM sys.server_principals l,
sys.database_principals u
WHERE l.sid = u.sid
AND u.name = 'Fyi_User';
GO
User_Name Login_Name sid
---------- ----------- ----------------------------------
Fyi_User Fyi_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5
(1 row(s) affected)
⇒ Verifying a User Name with SQLCMD Tool in SQL Server
⇐ sys.database_principals - Listing All User Names in SQL Server
2017-08-25, 3285🔥, 0💬
Popular Posts:
Why I Can Not Enter 0.001 Second in DATETIME values in SQL Server Transact-SQL? If you enter millise...
How To Format Time Zone in +/-hh:mm Format in SQL Server Transact-SQL? From the previous tutorial, y...
What Privilege Is Needed for a User to Delete Rows from Tables in Another Schema in Oracle? For a us...
What are single-byte character string data types supported in SQL Server Transact-SQL? Single-byte c...
How To Start the Command-Line SQL*Plus in Oracle? If you Oracle server or client installed on your w...