How do I create a new user in a SQL Azure database?

后端 未结 9 1713
礼貌的吻别
礼貌的吻别 2020-12-12 13:17

I am trying to use the following template:

-- =================================================
-- Create User as DBO template for SQL Azure Database
-- ====         


        
9条回答
  •  悲&欢浪女
    2020-12-12 13:41

    I followed the answers here but when I tried to connect with my new user, I got an error message stating "The server principal 'newuser' is not able to access the database 'master' under the current security context".

    I had to also create a new user in the master table to successfully log in with SSMS.

    USE [master]
    GO
    CREATE LOGIN [newuser] WITH PASSWORD=N'blahpw'
    GO
    CREATE USER [newuser] FOR LOGIN [newuser] WITH DEFAULT_SCHEMA=[dbo]
    GO
    
    USE [MyDatabase]
    CREATE USER newuser FOR LOGIN newuser WITH DEFAULT_SCHEMA = dbo
    GO
    EXEC sp_addrolemember N'db_owner', N'newuser'
    GO
    

提交回复
热议问题