5

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.

2
  • What are the permissions given to user , trying to alter database as mentioned above?
    – KASQLDBA
    Commented May 27, 2015 at 16:14
  • Is the user ( or login ) DBO?
    – Racer SQL
    Commented May 27, 2015 at 17:13

2 Answers 2

6

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

3
  • Granting alter permission does not allow a user to rename the database. Even if the user has db_owner permission on the database and dbcreator at the server level.
    – jclabonde
    Commented Feb 7, 2018 at 14:40
  • @jclabonde read OPs question carefully. OP is asking for modifying file size to unlimited and NOT asking to rename the database. What I posted works (i have tested it and then posted as answer). The point you are making is kind of valid when you have to rename the db (but that is not what OP is asking). Also to rename the db, you dont need to be in reader and writer role in master.
    – Kin Shah
    Commented Feb 8, 2018 at 18:13
  • What if this happens as 'sa' user and the database exists? (in other words, what does 'the database is not in a state that allows access checks' mean?)
    – golimar
    Commented Jun 3, 2021 at 8:19
0

Granting just alter to the specific database does not allow for the rename.

You must also grant permissions at the server level and in master.

USE master;  
ALTER SERVER ROLE [dbcreator] ADD MEMBER [DOMAIN\User-Name]
GO

USE master;    
ALTER ROLE [db_datareader] ADD MEMBER [DOMAIN\User-Name];
ALTER ROLE [db_datawriter] ADD MEMBER [DOMAIN\User-Name];

USE [AdventureWorks]
ALTER ROLE [db_owner] ADD MEMBER [DOMAIN\User-Name];  
2
  • I'm downvoting for recommending using a deprecated solution Commented Feb 7, 2018 at 15:22
  • Why you need reader and writer in master ?
    – Kin Shah
    Commented Feb 8, 2018 at 18:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.