title: SQL Query to get mapping of all users to their logins
body: <p>What's a query that I can use to get a list of all logins associated with each user in SQL Azure?</p>
  
  <p>So far I've found the following two queries to get all users and all logins, but I haven't found any way to see which user goes with which login:</p>
  
  <pre><code>SELECT * from sys.sql_logins -- get all logins
  SELECT * from sys.sysusers -- get all users
  </code></pre>
  
  <p>In case you find it helpful, here's the documentation for the structures of those the tables:</p>
  
  <p><strong>sys.sql_logins:</strong> 
  <a href="https://msdn.microsoft.com/en-us/library/ms174355.aspx?f=255&amp;MSPPError=-2147217396" rel="nofollow">https://msdn.microsoft.com/en-us/library/ms174355.aspx?f=255&amp;MSPPError=-2147217396</a></p>
  
  <p><strong>Column names:</strong> name, principal_id, sid, type, type_desc, is_disabled, create_date, modify_date, default_database_name, default_language_name, credential_id, is_policy_checked, is_expiration_checked, password_hash</p>
  
  <p><strong>sys.sysusers:</strong> <a href="https://msdn.microsoft.com/en-us/library/ms179871.aspx" rel="nofollow">https://msdn.microsoft.com/en-us/library/ms179871.aspx</a></p>
  
  <p><strong>Column names:</strong> uid, status, name, sid, roles, createdate, updatedate, altuid, password, gid, environ, hasdbaccess, islogin, isntname, isntgroup, isntuser, issqluser, isaliased, issqlrole, isapprole</p>