Wednesday, November 21, 2018

SQL - List Linked Servers and Logins

SQL - List Linked Servers and Logins

Probably need sysadmin role for this. Copied from the internet, need to find refernce.

SELECT    ss.name 
          ,ss.product 
          ,ss.provider 
          ,'Local Login ' = case sl.uses_self_credential 
                            when 1 then 'Uses Self Credentials' 
                            else ssp.name 
                            end 
           ,'Remote Login Name' = sl.remote_name 
           ,ss.modify_date 
      FROM sys.Servers ss 
 LEFT JOIN sys.linked_logins sl 
        ON ss.server_id = sl.server_id 
 LEFT JOIN sys.server_principals ssp 
        ON ssp.principal_id = sl.local_principal_id

No comments:

Post a Comment