Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

login to db user mapping/alias

Posted on 2004-09-10
2
Medium Priority
?
726 Views
Last Modified: 2006-11-17
Hi,
using Sybase Central on ASE 12.5.* if I examine a particular login the Users tab displays which users in  which databases are mapped to this login. e.g. by default the sa login is mapped to the dbo user in master, model, sybsystemdb and sybsystemprocs databases.

How can I pull this info out using SQL? syslogins and sysdatabases don't seem to have the right relationship? Can this be done with out querying each individual db?
0
Comment
Question by:skehanb
2 Comments
 
LVL 19

Accepted Solution

by:
grant300 earned 250 total points
ID: 12032552
You have to query the sysusers table in each database, however, it is not a problem if you know the databases you are interested in.  Just create a view in sybsystemprocs that does a UNION ALL query of the sysusers tables in all of the databases you are interested in.  Then you can join that to master..syslogins
or, for that matter, but the join right in the view.  Your done.

If you have to make the routine dynamic so that you don't have to know the database names ahead of time, just write a little stored procedure to get it for you.  Open a cursor on sysdatabases, create a temp table, build a dynamic sql statement to insert/select the contents of each sysusers table into the temp table, then join that mess with syslogins and you are done.

Hope that helps.

Bill
0
 
LVL 6

Expert Comment

by:ChrisKing
ID: 12033080
Rob Verschoor (www.sypron.nl) has a lot of handy little utilities for just such a purpose:

There are many of them but the one that I am think of is "sp_rv_exec" that executes a procedure in every database.

Rob's examples show:
exec sp_rv_exec "sp_adduser", "jsmith"                          -- adds user "jsmith" to all databases
exec sp_rv_exec "sp_addtype", "newtype", "char(25)"      -- adds datatype "newtype" to all databases

so why not:
exec sp_rv_exec "sp_helpuser", "fred"

check it out at http://www.sypron.nl/new_ssp.html
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Take a look at these 6 Outlook Email management tools which can augment the working and performance of Microsoft Outlook to give you a more rewarding emailing experience.
Aerodynamic noise is the cause of the majority of the noise produced by helicopters. The inordinate amount of noise helicopters produce is a major problem in the both a military and civilian setting. To remedy this problem the use of an aerogel coat…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
Suggested Courses

886 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