I have a database server with several databases inside. This server is used as test server to store a set of test databases. The test databases do not come from the same production server thus I can have a mixed context where multiple test databases in test server come from different production servers. The logins and the mapped users in all the production servers have the same name but indeed their login passwords are different.
I use a Powershell Azure CLI script in order to copy the production databases from their source production server and restore them in the unique target test database.
The issue is that there is an inconsistent state between the mapping of the logins in the test server and the user in the test database, since even though they got the same name their identifier is probably different.
How can I map the test server login password to each user in the databases by using the name as a matching criteria?
ALTER
the users so that they are linked to the rightLOGIN
; which presumably is the one with the same name (though this is not always the case).