Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

Query Multiple Databases Expand / Collapse
Author
Message
Posted Friday, April 12, 2013 12:17 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 9:00 AM
Points: 103, Visits: 280
I am finding that you have to replace the single quotes with double quotes in some cases.



Jeff
Post #1441837
Posted Friday, April 12, 2013 12:19 PM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: 2 days ago @ 9:00 AM
Points: 103, Visits: 280
I am finding tha I have to replace single quotes with double qoutes for the queries to work.

Jeff
Post #1441839
Posted Friday, April 12, 2013 12:43 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:05 PM
Points: 13,327, Visits: 12,820
It would be advisable to use the ANSI-92 style joins instead of the much older comma separated list. Your query would look like this.

SELECT p.name as [User], r.name as [Role]
FROM sys.database_principals p
join sys.database_role_members m on p.principal_id = m.member_principal_id
join sys.database_principals r on r.principal_id = m.role_principal_id
WHERE m.role_principal_id = 16384
ORDER BY r.name, p.name



_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1441847
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse