SQLQuickfixes

Nothing loose by learning again. Definitely gain If you just don't let it go away. - Bvsc.

Pages

  • Home
  • SQL2012 - Denali
  • SQL Server 2014 - SQL14

Tuesday, December 14, 2021

Get all databases a login can access

-- First Check you have access in all the databases in your system..

SELECT s.* FROM master.sys.databases s WHERE HAS_DBACCESS(s.name) = 1

-- List all the databases a login can access in the system.

EXECUTE AS LOGIN = 'Sl_Mwbe_write'  

SELECT s.name FROM master.sys.databases s

WHERE HAS_DBACCESS(s.name) = 1

REVERT

Posted by PraveenSynick at 7:58 AM No comments:
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Newer Posts Older Posts Home
Subscribe to: Posts (Atom)

Blog Archive

  • ►  2022 (1)
    • ►  March (1)
  • ▼  2021 (1)
    • ▼  December (1)
      • Get all databases a login can access
  • ►  2020 (2)
    • ►  February (2)
  • ►  2018 (1)
    • ►  August (1)
  • ►  2017 (2)
    • ►  March (1)
    • ►  January (1)
  • ►  2015 (12)
    • ►  June (1)
    • ►  May (1)
    • ►  April (5)
    • ►  March (2)
    • ►  February (1)
    • ►  January (2)
  • ►  2014 (10)
    • ►  December (4)
    • ►  November (2)
    • ►  October (1)
    • ►  May (1)
    • ►  April (1)
    • ►  February (1)
  • ►  2013 (12)
    • ►  December (1)
    • ►  November (5)
    • ►  April (5)
    • ►  January (1)
  • ►  2012 (14)
    • ►  December (3)
    • ►  November (5)
    • ►  October (6)

About Me

PraveenSynick
View my complete profile
Watermark theme. Powered by Blogger.