I'm a user of a SQL Sever database, and I want to know my access rights / permissions in the database I'm using. What SQL query should I use to do so?
Thanks
I'm a user of a SQL Sever database, and I want to know my access rights / permissions in the database I'm using. What SQL query should I use to do so?
Thanks
I think the easiest way would be:
SELECT * FROM fn_my_permissions(NULL, 'SERVER');
GO
I tried it in SQL Server 2008.
SELECT * FROM fn_my_permissions(NULL, 'DATABASE'); GO
–
Trumpet If you're looking for what you might be missing as well as what you have, here's a useful way to find it:
SELECT all_permissions.permission_name, p.name
FROM (
SELECT DISTINCT permission_name
FROM sys.database_permissions
) all_permissions
LEFT JOIN (
SELECT b.name, a.permission_name
FROM sys.database_permissions a
JOIN sys.database_principals b on a.grantee_principal_id = b.principal_id
WHERE b.name = '{YOUR_NAME_OR_GROUP_NAME_HERE}'
) p ON p.permission_name = all_permissions.permission_name
SELECT * FROM sys.database_principals
. You could be in a nested group or not prefixing the username as expected. If it still isn't working, it would be more helpful to tell us the version you're using instead of just saying it doesn't work, when it's working for others. –
Hemminger © 2022 - 2024 — McMap. All rights reserved.