The server principal is not able to access the database under the current security context in SQL Server MS 2012

后端 未结 10 789
-上瘾入骨i
-上瘾入骨i 2020-12-13 01:46

I am trying to access my hosting server’s database through SQL Server Management Studio, everything till login is fine but when I use the command use myDatabase

10条回答
  •  囚心锁ツ
    2020-12-13 02:25

    In my case, the message was caused by a synonym which inadvertently included the database name in the "object name". When I restored the database under a new name, the synonym still pointed to the old DB name. Since the user did not have permissions in the old DB, the message appeared. To fix, I dropped and recreated the synonym without qualifying the object name with the database name:

        USE [new_db]
    GO
    
    /****** Object:  Synonym [dbo].[synTable]    Script Date: 10/15/2015 9:45:01 AM ******/
    DROP SYNONYM [dbo].[synTable]
    GO
    
    /****** Object:  Synonym [dbo].[synTable]    Script Date: 10/15/2015 9:45:01 AM ******/
    CREATE SYNONYM [dbo].[synTable] FOR [dbo].[tTheRealTable]
    GO
    

提交回复
热议问题