如何查找登录用户是否有权在SQL Server上查看“查看”定义?我需要找出一个视图的表/列,
我使用这个SQL是一样的;对于视图定义,我们使用了这个查询:
查询:
select *
from sys.objects
where name like '%SECTION_MASTER_V%'
结果:579337674
查询:
SELECT definition
FROM sys.objects o
JOIN sys.sql_modules m ON m.object_id = o.object_id
WHERE o.object_id = 579337674
AND o.type = 'V'
结果: null
结果我得到null。有谁知道这里可能有什么问题?
答案 0 :(得分:0)
您可以使用此查询查看对象级权限:WHERE
子句中的已注释部分会将结果限制为VIEW DEFINITION
权限。
SELECT
o.name AS ObjectName,
su.name AS LoginName,
dp.permission_name AS PermissionType,
dp.state_desc AS PermissionStatus
FROM
sys.database_permissions dp
INNER JOIN
sys.objects o ON
dp.major_id = o.object_id
INNER JOIN
sys.sysusers su ON
dp.grantee_principal_id = su.uid
--WHERE dp.[type] = 'vw'
ORDER BY o.name
答案 1 :(得分:-1)
两件事: