Solved

How do I get the DB Username from LoginName?

Posted on 2007-11-23
6
485 Views
Last Modified: 2013-11-06
Using T-SQL:

I know the LOGIN NAME of a user. How can I find the USER NAME that is associated with the login name for a particular database?

Thanks
Bob

0
Comment
Question by:rcl58
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3
6 Comments
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20340440
check out the master.sys.syslogins sid column vs the databases.sys.sysusers sid column ...
0
 

Author Comment

by:rcl58
ID: 20340538
angelIII,

Thanks for your help. I am just trying to drop a user's login and database user. Since I know the Login Name I can drop the login easily but I don't see a T-SQL command to drop a user from a database using the Login Name or SID. How would I do this? Do I have to directly access tables in the master database?

Thanks again,
Bob
0
 
LVL 143

Expert Comment

by:Guy Hengel [angelIII / a3]
ID: 20340548
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 

Author Comment

by:rcl58
ID: 20340604
Sorry for being slow but I still don't follow.

e.g. Say login name is [mydomain\bsmith] and my user name is [bob]

If I only know the login name how can I find the user name? DROP USER requires the user name.

Thanks
Bob
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 100 total points
ID: 20340634
select l.name login_name, u.name user_name
from master.sys.syslogins l
join reportserver.sys.sysusers u
  on u.sid = l.sid
where l.name = 'mydomain\bsmith'
0
 

Author Comment

by:rcl58
ID: 20340699
Thanks again
0

Featured Post

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

How to install Selenium IDE and loops for quick automated testing. Get Selenium IDE from http://seleniumhq.org Go to that link and select download selenium in the right hand column That will then direct you to their download page. From that p…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
THe viewer will learn how to use NetBeans IDE 8.0 for Windows to perform CRUD operations on a MySql database.

734 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question