登录的 SQL 查询

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37275/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 23:12:20  来源:igfitidea点击:

SQL Query for Logins

sqlsql-server

提问by Jim

What is the SQL query to select all of the MSSQL Server's logins?

选择所有 MSSQL Server 登录名的 SQL 查询是什么?

Thank you. More than one of you had the answer I was looking for:

谢谢你。不止一个人得到了我一直在寻找的答案:

SELECT * FROM syslogins 

回答by Brad Wilson

Is this what you're after?

这是你追求的吗?

select * from master.syslogins

回答by DeepSpace101

On SQL Azure as of 2012;

2012 年在 SQL Azure 上;

logins:

登录:

SELECT * from master.sys.sql_logins

users:

用户:

SELECT * from master.sys.sysusers

回答by Matt Hamilton

EXEC sp_helplogins

You can also pass an "@LoginNamePattern" parameter to get information about a specific login:

您还可以传递“@LoginNamePattern”参数以获取有关特定登录的信息:

EXEC sp_helplogins @LoginNamePattern='fred'

回答by aku

@allain, @GateKiller your query selects users not logins
To select logins you can use this query:

@allain,@GateKiller 您的查询选择用户而不是登录
要选择登录,您可以使用此查询:

SELECT name FROM master..sysxlogins WHERE sid IS NOT NULL

In MSSQL2005/2008 syslogins table is used insted of sysxlogins

在 MSSQL2005/2008 syslogins 表中使用了 sysxlogins

回答by BradC

Starting with SQL 2008, you should use sys.server_principalsinstead of sys.syslogins, which has been deprecated.

从 SQL 2008 开始,您应该使用sys.server_principals代替sys.syslogins它已被弃用

回答by Matt Hamilton

Selecting from sysusers will get you information about userson the selected database, not loginson the server.

从 sysusers 中选择将获得有关所选数据库上的用户的信息,而不是服务器上的登录信息。

回答by Matt Hamilton

sp_helplogins will give you the logins along with the DBs and the rights on them.

sp_helplogins 将为您提供登录名以及 DB 及其权限。

回答by GateKiller

Select * From Master..SysUsers Where IsSqlUser = 1

回答by Jason

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.

查看主模式中的 syslogins 或 sysusers 表。不确定这在最近的 MSSQL 版本中是否仍然存在。在 MSSQL 2005 中有称为 sys.syslogins 和 sys.sysusers 的视图。