Monday, 17 August 2020

Create Azure SQL User and add a sql role

I wanted to add a new sql user "sqluser" in Azure SQL server to access a database "sanjeeb". 

Steps to create a new SQL user. 

1) Connect to the Azure sql server with existing user using Microsoft SQL Server Management studio

2) Open new query window under Master database


3) Run the below script
    
    CREATE LOGIN [sqllogin] WITH PASSWORD = 'verystrongpassword#1' 
   



4) Open new query window under database "sanjeeb"

5) Run the below script

CREATE USER [sqluser]
FOR LOGIN [sqllogin]
WITH DEFAULT_SCHEMA =  dbo
GO

-- Add user to the database owner role
EXEC sp_addrolemember N'db_owner', N'sqluser'
GO

6) You've now created a user login "sqllogin", user account "sqluser" and added the user to "db_owner role"



7) Connect to the database using the new user login account. 

login: sqllogin
password:verystrongpassword#1


8) Click Options and select Connection properties tab

9) input Connect to database = sanjeeb

10) Click connect

2 comments:

  1. Your contents are completely awesome and share worthy. I really appreciate your efforts that you put on this. Keep sharing.

    C++ Training Institute in Delhi

    ReplyDelete
  2. You have made your points in a smart way. I am impressed with how interesting you have been able to present this content. Thanks for sharing nice information.

    Graphic Design Courses in South Delhi

    ReplyDelete

How to give SQL User access to execute Stored procedures and read/write access to database

Assumptions: stored procedures and tables are created under schema dbo. in case different schema, change the below code accordingly.   --Cre...