At this time, it is not possible to solve the login problem by creating a new login or granting the "user" permission of the corresponding database to the login with the same name , because SQL Server will report "Error 15023: There is already a user or role in the current database".In order to solve this problem, Need to call the system stored procedure sp_change_users_login, the specific usage is as follows:
Use database name
sp_change_users_login'update_one',' user name' ,' user name'
where the database name is the database with orphaned users, update_one is the parameter of the stored procedure, which means that only one is processed User, the first user name is the database user, and the latter user name is used for database login.The above SQL command means to reconnect the database user user name with the server login user name . In this way, the database can be used normally.