SQL DBA qeries to fix

Krish 81 Reputation points
2020-09-09T06:56:15.09+00:00

TITLE: Microsoft SQL Server Management Studio


Cannot show requested dialog.


ADDITIONAL INFORMATION:

Cannot show requested dialog. (SqlMgmt)


An exception occurred while executing a Transact-SQL statement or batch. (Microsoft.SqlServer.ConnectionInfo)


The server principal "test" is not able to access the database "DB_New" under the current security context. (Microsoft SQL Server, Error: 916)

For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&ProdVer=13.00.5264&EvtSrc=MSSQLServer&EvtID=916&LinkId=20476

I googled for error 916 this is not solving the problem.
In the data base collation is proper.

SQL Server Other
{count} votes

2 answers

Sort by: Most helpful
  1. m 4,276 Reputation points
    2020-09-09T10:19:13+00:00

    Hi @kirankumar-3620,

    Error 916 means the login does not have sufficient permissions to connect to the named database.

    Try code as next to check whether the user have connect permission:

    SELECT * FROM sys.database_principals dprinc  
    INNER JOIN sys.database_permissions dperm  
    ON dprinc.principal_id = dperm.grantee_principal_id  
    WHERE dprinc.name = '<username>' AND dperm.permission_name = 'CONNECT'  
    

    And if not, grant connect permission as next:

    USE Dbname  
    GO  
      
    CREATE USER UserName FROM LOGIN LoginName /*if you already have one, you can skip this step*/  
    GO  
      
    GRANT CONNECT TO UserName  
    GO  
    

    Note: The login “LoginName” needs set up in the database as a "User". By default, all users are a member of the database public role.

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

  2. m 4,276 Reputation points
    2020-09-10T01:48:06.197+00:00

    Hi @kirankumar-3620,

    Is the reply helpful?

    BR,
    Mia


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    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.