<p>What is the SQL query to select all of the MSSQL Server's logins?</p>

<p>Thank you.  More than one of you had the answer I was looking for:</p>

<pre><code>SELECT * FROM syslogins 
</code></pre>

[{'answer_id': 37280, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 4, 'selected': False, 'text': '<pre><code>EXEC sp_helplogins\n</code></pre>\n\n<p>You can also pass an "@LoginNamePattern" parameter to get information about a specific login:</p>\n\n<pre><code>EXEC sp_helplogins @LoginNamePattern=\'fred\'\n</code></pre>\n'}, {'answer_id': 37284, 'author': 'GateKiller', 'author_id': 383, 'author_profile': 'https://Stackoverflow.com/users/383', 'pm_score': 2, 'selected': False, 'text': '<pre><code>Select * From Master..SysUsers Where IsSqlUser = 1\n</code></pre>\n'}, {'answer_id': 37286, 'author': 'aku', 'author_id': 1196, 'author_profile': 'https://Stackoverflow.com/users/1196', 'pm_score': 2, 'selected': False, 'text': '<p>@allain, @GateKiller your query selects users not logins<br>\nTo select logins you can use this query:  </p>\n\n<pre><code>SELECT name FROM master..sysxlogins WHERE sid IS NOT NULL\n</code></pre>\n\n<p>In MSSQL2005/2008 syslogins table is used insted of sysxlogins</p>\n'}, {'answer_id': 37287, 'author': 'Jason', 'author_id': 1072, 'author_profile': 'https://Stackoverflow.com/users/1072', 'pm_score': 1, 'selected': False, 'text': '<p>Have a look in the syslogins or sysusers tables in the master schema. Not sure if this still still around in more recent MSSQL versions though. In MSSQL 2005 there are views called sys.syslogins and sys.sysusers.</p>\n'}, {'answer_id': 37288, 'author': 'Matt Hamilton', 'author_id': 615, 'author_profile': 'https://Stackoverflow.com/users/615', 'pm_score': 2, 'selected': False, 'text': '<p>Selecting from sysusers will get you information about <em>users</em> on the selected database, not <em>logins</em> on the server.</p>\n'}, {'answer_id': 37290, 'author': 'Brad Wilson', 'author_id': 1554, 'author_profile': 'https://Stackoverflow.com/users/1554', 'pm_score': 7, 'selected': True, 'text': "<p>Is this what you're after?</p>\n\n<pre><code>select * from master.syslogins\n</code></pre>\n"}, {'answer_id': 1201153, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 2, 'selected': False, 'text': '<p>sp_helplogins will give you the logins along with the DBs and the rights on them.</p>\n'}, {'answer_id': 13436833, 'author': 'DeepSpace101', 'author_id': 862563, 'author_profile': 'https://Stackoverflow.com/users/862563', 'pm_score': 5, 'selected': False, 'text': "<p>On SQL Azure as of 2012;</p>\n<p>logins:</p>\n<pre><code>    --connecct to master\n\n    --logins\n    SELECT * from sys.sql_logins\n    --users\n    SELECT * from sys.sysusers\n</code></pre>\n<p>and users on a specific database:</p>\n<pre><code>    --connect to database\n    SELECT * from sys.sysusers\n</code></pre>\n<p>Also note that 'users' on Azure SQL now (2022-11-17) have more 'login' type properties and creating a user on a Azure SQL database with a password is now possible, so it is less likely to require creating logins in 'master'.</p>\n"}, {'answer_id': 42567127, 'author': 'BradC', 'author_id': 21398, 'author_profile': 'https://Stackoverflow.com/users/21398', 'pm_score': 3, 'selected': False, 'text': '<p>Starting with SQL 2008, you should use <a href="https://msdn.microsoft.com/en-us/library/ms188786.aspx" rel="noreferrer"><code>sys.server_principals</code></a> instead of <code>sys.syslogins</code>, <a href="https://msdn.microsoft.com/en-us/library/ms178593.aspx" rel="noreferrer">which has been deprecated</a>.</p>\n'}]
['https://Stackoverflow.com/questions/37275', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1208/']