how to check user privileges on a table in SQL Server

SELECT SUSER_NAME(), USER_NAME();

SELECT
HAS_PERMS_BY_NAME
(
N’dbo.QTest’,
N’OBJECT’,
N’DELETE’
);

EXECUTE AS LOGIN = ‘TestUser’;

–Verify the execution context is now login1.
SELECT SUSER_NAME(), USER_NAME();
SELECT
HAS_PERMS_BY_NAME
(
N’dbo.QTest’,
N’OBJECT’,
N’DELETE’
);
REVERT;
–Display current execution context.
SELECT SUSER_NAME(), USER_NAME();

Leave a Reply

Your email address will not be published. Required fields are marked *