After a locally debugged database is restored to the server, it finds that the user name of the database has followed the database. (This is a record in the database system table. Can this happen ?), However, if the login name is not used, you just want to create a login name for the user. However, when creating the login name, you may find it out of security considerations, the created login name cannot be used to operate the database. indicates that "user, group, or role 'xxx' already exists in the current database
If you want to manually associate the login name with the username in the database, the system will not let it; if you want to delete the user in the database, you will not be allowed to delete it again ......
In the end, we found that this situation is called "an isolated user". In fact, we can use the system's storage process sp_change_users_login:
The following parameters are explained:
ABC, not to mention, the database that you want to operate on.
Update_one, indicating that only one user is operated
Xxx and XXX are the login names of SQL Server and the usernames in the database respectively.
For more detailed usage of sp_change_users_login, refer to SQL Server online help.