HiveBrain v1.2.0
Get Started
← Back to all entries
patternsqlMinor

Permissions required to alter a database file

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
filepermissionsdatabasealterrequired

Problem

Totally at the beginning in administering a database.

Using EMS SQL Manager ... latest version. How do I over come below

ALTER DATABASE joneslocker2
MODIFY FILE (
    NAME = joneslocker2, 
    MAXSIZE = UNLIMITED )
GO


which results in an error:


User does not have permission to alter database 'joneslocker2', the
database does not exist, or the database is not in a state that allows
access checks.

I don't have a clue what to set next.

Solution

You need to GRANT ALTER DATABASE permission to the user.

GRANT ALTER ON DATABASE:: joneslocker2 TO username


Below script will help you to find what permissions are assigned at the database level :

SELECT prin.[name] [User], sec.state_desc + ' ' + sec.permission_name [Permission] 
FROM [sys].[database_permissions] sec 
  JOIN [sys].[database_principals] prin 
    ON sec.[grantee_principal_id] = prin.[principal_id] 
WHERE sec.class = 0 
ORDER BY [User], [Permission];


Check my answer here for an example on why you are getting the error.

Refer to : Database Engine Permission Basics

Code Snippets

GRANT ALTER ON DATABASE:: joneslocker2 TO username
SELECT prin.[name] [User], sec.state_desc + ' ' + sec.permission_name [Permission] 
FROM [sys].[database_permissions] sec 
  JOIN [sys].[database_principals] prin 
    ON sec.[grantee_principal_id] = prin.[principal_id] 
WHERE sec.class = 0 
ORDER BY [User], [Permission];

Context

StackExchange Database Administrators Q#102577, answer score: 6

Revisions (0)

No revisions yet.