A SQL Server Login authenticates against the SQL Server. ItAfter the login the SQL Server looks if the SQL Server Login is associated with a Database User in the database it is trying to access.
The Database User has the privileges to modify or view data in the database.
When you restore If a database from one server to another then you are transporting the Database Users within the backup. Howeverlink exists, then the SQL Server Logins are not transported withLogin is able to modify data in the database backupvie the permissions assigned to the Database User.
When you restore a database from one server to another then you are transporting the Database Users within the backup. However, the SQL Server Logins are not transported with the database backup.
Option 1: Create a SQL Server Login with the same password.
Option 2: Backup the SQL Server Login on the old SQL Server and transport to the new server.
Option 3: Use Windows Authenticated Accounts/Groups
Option 4: Use some 3rd party tool
Option 5: Relink the SQL Server Login with the Database User
Things To Look Atpublic Role
The public role is a built-in role and can't be assigned directly (explicit) it is assigned automatically, when a SQL Server Login is linked to a Database User:
Every database user belongs to the public database role. When a user hasn't been granted or denied specific permissions on a securable object, the user inherits the permissions granted to public on that object. Database users cannot be removed from the public role.
Reference: Database Level Roles - Public Role (Microsoft | SQL Docs)
Reference Reading
- SQL Server Logins (Microsoft | SQL Docs)
- Create a Database User (Microsoft | SQL Docs)
- How to Back Up and Restore SQL Server Logins (Microsoft)
- database.ioDBA Tools (DBATools.IO)
- Database Level Roles - Public Role (Microsoft | SQL Docs)