Share via

Sync login with SID in Azure SQL DB

Vijay Kumar 2,061 Reputation points
2022-02-17T02:42:43.26+00:00

Hi ,

I have restored the Azure PROD DB copy to Azure QA DB

In Azure QA master DB already contains users

Now how to sync login SID's from master db to QA user DB?

Azure SQL Database

Answer accepted by question author

  1. Alberto Morillo 35,506 Reputation points MVP Volunteer Moderator
    2022-02-17T02:56:47.813+00:00

    Let's say you have created a login on the master database named TestUser as shown below"

    ---- ON Master Level  
    CREATE USER TestUser  
        FOR LOGIN TestUser  
        WITH DEFAULT_SCHEMA = dbo  
    

    To create that login as a user on the QA database, connect to the QA database and run the following query:

    ---- ON SQL DB LEVEL  
    CREATE USER TestUser  
        FOR LOGIN TestUser  
        WITH DEFAULT_SCHEMA = dbo  
    GO  
    

    After that grant the user appropriate permissions to objects.

    GRANT SELECT ON OBJECT::dbo.Sales TO TestUser;  
    GO  
    

    You can see the mapping between SIDs if you do as explained here.

    Was this answer helpful?

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.