Cannot access the database with the assigned privilege

Avyayah 1,291 Reputation points
2021-05-27T15:33:04+00:00

100324-cannotaccessdatabase.jpg

Sa is disable and do not have the password. My user does not have sysadmin privileges and cannot add account with sysadmin privileges.
This statement does not work,
USE YourDBName
GO
sp_changedbowner 'sa'
GO

This is SQLServer 2014,
Check this link https://dba.stackexchange.com/questions/61722/cannot-access-properties-page-of-a-database
Will the detach and attach the database fix this issue.

SQL Server Other
{count} votes

Accepted answer
  1. Erland Sommarskog 121.4K Reputation points MVP Volunteer Moderator
    2021-05-28T21:29:45.727+00:00

    The server principal "username" is not able to access the database "dbname" under the current security context.

    Well, that explains it all, and there is not much we can do about it here. If you don't have access to that database, and you are not sysadmin, and you need permission to that database, you will need to find someone who can grant you those permissions.

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. CathyJi-MSFT 22,396 Reputation points Microsoft External Staff
    2021-05-28T02:33:59.887+00:00

    Hi @Avyayah ,

    > Property Owner is not available for Database '[database name]'. This property may not exist for this object, or may not be retrievable due to insufficient access rights

    Please ran the system stored procedure sp_helpdb to check the database properties, check the value of owner column.

    sp_helpdb  YourDBName  
    

    If the owner column was set to UNKNOWN, you can quickly resolve this issue by running following command in your query window. Please ask help for the sysadmin user to help you resolve your issue, since your account is not a sysadmin account, you do not have the permission to run the query.

    USE YourDBName  
    GO  
    sp_changedbowner 'sa'  
    GO  
    

    Run this query requires TAKE OWNERSHIP permission on the database. If the new owner has a corresponding user in the database, requires IMPERSONATE permission on the login, otherwise requires CONTROL SERVER permission on the server. Refer to MS document sp_changedbowner (Transact-SQL)

    Please refer below blogs to get more information;

    Property Owner is not available for Database SSMS error
    SQL SERVER – Fix – Error – Property MemoryAllocatedToMemory OptimizedObjectsInKB is not available for Database. This property may not exist for this object, or may not be retrievable due to insufficient access rights.

    By the way, suggest you using the latest version SSMS 18.9.1 to connect to SQL server 2014 as Tom mentioned.


    If the response is helpful, please click "Accept Answer" and upvote it, as this could help other community members looking for similar queries.

    1 person found this answer helpful.
    0 comments No comments

  2. Tom Phillips 17,771 Reputation points
    2021-05-27T19:17:02.623+00:00

    The error you posted is caused when using an old version of SSMS to connect to a newer version of SQL Server.

    Please download and install the current version of SSMS.
    https://learn.microsoft.com/en-us/sql/ssms/download-sql-server-management-studio-ssms?view=sql-server-ver15

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.