SQL Server 2000 - 使用 GRANT EXECUTE 专门查看特定角色的存储过程列表?

发布于 2024-08-14 02:51:36 字数 257 浏览 5 评论 0原文

我的 SQLSERVER 2000 数据库中有大约 500 个存储过程;每个存储过程都有一个类似于以下内容的典型 Grant Execute 语句。

在 [dbo].[sproc_name]
上授予执行权限 TO [role1]、[role2]、[role3]、[role4] 等...

如何查看已授予特定角色并且仅授予该特定角色的存储过程的名称。

例如,我不希望角色1与角色2或角色3组合,我只想查看只有角色1本身具有执行权限的角色。

There are approx 500 sprocs in my SQLSERVER 2000 database; each sproc has a typical Grant Execute statement similar to the following.

GRANT EXECUTE ON [dbo].[sproc_name]
TO [role1], [role2], [role3], [role4], etc...

How to view the names of the sprocs which have grant to a particular role and only that particular role exclusively.

For example, i DO NOT want role1 in combination with role2, or role3, i just want to view the ones where only role1 by itself has execute permission.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

你曾走过我的故事 2024-08-21 02:51:36

这是针对 SQL Server 2000 的:

SELECT
    OBJECT_NAME(p1.id)
FROM
    syspermissions p1
WHERE
    USER_NAME(p1.grantee) = 'MyRole'
    AND
    OBJECT_NAME(p1.id) = 'MyProc'
    AND
    NOT EXISTS (SELECT *
        FROM
            syspermissions p2
        WHERE
            p1.grantee <> p2.grantee
            AND
            p1.id = p2.id)

This is for SQL Server 2000:

SELECT
    OBJECT_NAME(p1.id)
FROM
    syspermissions p1
WHERE
    USER_NAME(p1.grantee) = 'MyRole'
    AND
    OBJECT_NAME(p1.id) = 'MyProc'
    AND
    NOT EXISTS (SELECT *
        FROM
            syspermissions p2
        WHERE
            p1.grantee <> p2.grantee
            AND
            p1.id = p2.id)
爺獨霸怡葒院 2024-08-21 02:51:36

基于 gbn 的回答。这是比较合适的,但本质上他提供了答案。

-- show all stored procs where permission is granted to 'MyRole' and only 'MyRole'
SELECT OBJECT_NAME(p1.id) AS sproc_name
  FROM    syspermissions p1
  inner join sysobjects o ON p1.id = o.id
    AND o.xtype = 'p'
    AND o.[name] not like 'dt_%'
WHERE USER_NAME(p1.grantee) = 'MyRole'
AND NOT EXISTS (
        SELECT *        
            FROM  syspermissions p2        
        WHERE p1.grantee <> p2.grantee            
        AND p1.id = p2.id
    )
ORDER BY 1

Based on the answer by gbn. This is more appropriate, but essentially he provided the answer.

-- show all stored procs where permission is granted to 'MyRole' and only 'MyRole'
SELECT OBJECT_NAME(p1.id) AS sproc_name
  FROM    syspermissions p1
  inner join sysobjects o ON p1.id = o.id
    AND o.xtype = 'p'
    AND o.[name] not like 'dt_%'
WHERE USER_NAME(p1.grantee) = 'MyRole'
AND NOT EXISTS (
        SELECT *        
            FROM  syspermissions p2        
        WHERE p1.grantee <> p2.grantee            
        AND p1.id = p2.id
    )
ORDER BY 1
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文