Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
How To Find the Login Name Linked to a Given User Name?
Submitted by: AdministratorIf 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:
* Each login name is associated a unique SID.
* When a user name is linked to a login name, the login name's SID is copied to the user name.
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 "ggl_User":
-- Login with sa
USE GlobalGuideLineDatabase;
GO
<pre>
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 = 'ggl_User';
GO
User_Name Login_Name sid
---------- ----------- ----------------------------------
ggl_User ggl_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5</pre>
(1 row(s) affected)
Submitted by: Administrator
* Each login name is associated a unique SID.
* When a user name is linked to a login name, the login name's SID is copied to the user name.
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 "ggl_User":
-- Login with sa
USE GlobalGuideLineDatabase;
GO
<pre>
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 = 'ggl_User';
GO
User_Name Login_Name sid
---------- ----------- ----------------------------------
ggl_User ggl_Login 0x5EB8701EAEBAA74F86FCF5BD8E37B8C5</pre>
(1 row(s) affected)
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.