0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

DB上のユーザーにFunction実行の権限を与える

Last updated at Posted at 2023-09-06

権限確認

--DBを指定
USE [sampleDB]

SELECT
    USER_NAME(grantee_principal_id) AS ユーザー名,
    class_desc AS クラス,
    OBJECT_NAME(major_id) AS オブジェクト名,
    permission_name as 権限名
FROM sys.database_permissions
WHERE grantee_principal_id = USER_ID('sampleDbRole') --ユーザー名 or ロール名を指定

権限付与

Functionまたはストアドプロシージャ毎、もしくはschema単位どちらか指定できる。

参考
https://learn.microsoft.com/ja-jp/sql/relational-databases/stored-procedures/grant-permissions-on-a-stored-procedure?view=sql-server-ver16#to-grant-permissions-on-a-stored-procedure-1

今回はあるファンクションのみ必要

--DBを指定
USE [sampleDB];

GRANT EXECUTE --実行のみ
ON OBJECT::<Schema>.<Function or StoredProcedure>  
    TO USERNAME;  
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?