How to create a user in Azure SQL database

If you want to create a user in the Azure SQL database, it’s quite easy. This article will discuss how to create a user in Azure SQL database.

How to create a user in Azure SQL database

You can follow the below steps to create a user in the Azure SQL database.

Creating a user in the Azure SQL Database involves the below key steps

  • First, you must connect to the Azure SQL Database server with the SQL Server Management Studio as an admin in Master.
  • Now you need to create a login (SQL Authentication) called “xyz” with a Password “Abc@1234”.
  • The next step is to create a user and then map the user to the login XYZ you have created.
  • Finally, You need to add it to the db_datawriter and db_datareader roles.

Make sure to run the below query on the Master

CREATE LOGIN xyz 
WITH PASSWORD = 'Abc@1234' 

Now choose the DB as User and run the below query

CREATE USER [xyz] 
FOR LOGIN [xyz] 
WITH DEFAULT_SCHEMA = dbo; 
  
-- adding user to roles
ALTER ROLE db_datareader ADD MEMBER [xyz]; 
ALTER ROLE db_datawriter ADD MEMBER [xyz]; 

You may also like following the articles below

Conclusion

This article discussed how to create user in Azure SQL database. Thanks for reading this article !!!