Create User in Microsoft SQL Server & Microsoft Azure SQL Database

You can create the user in Microsoft SQL Server & Microsoft Azure SQL Database using the following code.

  1. Connect to master database and execute the following script:

    CREATE LOGIN UserNameHere WITH password='Password here';
    CREATE USER UserNameHere FROM LOGIN UserNameHere;
    
  2. Then connect to the desired database and execute the following script:

    CREATE USER UserNameHere FROM LOGIN UserNameHere ;
    EXEC sp_addrolemember 'db_datareader', 'UserNameHere';
    

We have added newly created user to data reader role, you can add user to whatever roles you want.

Comments
Share it

Leave a Comment

Your email address will not be published. Required fields are marked *