我需要一个查询来显示有关SQLServer 2000和SQLServer 2005数据库中的用户,角色和权限的信息吗?
答案 0 :(得分:2)
登录在这里:
SQL Server 2000: 从master.dbo.syslogins
中选择*SQL Server 2005: select * from master.sys.logins
用户(按当前数据库):
SQL Server 2000: 从dbo.sysusers中选择*
SQL Server 2005: select * from sys.users
来自Books Online:
如何查找指定中包含的实体的所有所有者 架构? [运行以下内容之前 查询,替换
<database_name>
和 具有有效名称的<schema_name>
。
USE <database_name>;
GO
SELECT 'OBJECT' AS entity_type
,USER_NAME(OBJECTPROPERTY(object_id, 'OwnerId')) AS owner_name
,name
FROM sys.objects WHERE SCHEMA_NAME(schema_id) = '<schema_name>'
UNION
SELECT 'TYPE' AS entity_type
,USER_NAME(TYPEPROPERTY(SCHEMA_NAME(schema_id) + '.' + name, 'OwnerId')) AS owner_name
,name
FROM sys.types WHERE SCHEMA_NAME(schema_id) = '<schema_name>'
UNION
SELECT 'XML SCHEMA COLLECTION' AS entity_type
,COALESCE(USER_NAME(xsc.principal_id),USER_NAME(s.principal_id)) AS owner_name
,xsc.name
FROM sys.xml_schema_collections AS xsc JOIN sys.schemas AS s
ON s.schema_id = xsc.schema_id
WHERE s.name = '<schema_name>';
GO