T-SQL: Remap SQL users – Schelstraete.orghttps://www.schelstraete.org
I.T. minded
Sat, 16 Feb 2019 14:19:17 +0000 en-US
hourly
1 https://wordpress.org/?v=5.1.1T-SQL: Remap SQL usershttps://www.schelstraete.org/t-sql-remap-sql-users/
https://www.schelstraete.org/t-sql-remap-sql-users/#respondMon, 11 Feb 2019 20:21:34 +0000http://www.schelstraete.org/?p=99Read More]]>If you copy (backup/restore) a database from system A to system B, it is possible that the SQL users won’t be able login and this because the GUID/SID of the users on system A doesn’t match the GUID/SID of system B.

It is using the EXEC sp_change_users_login ‘Auto_Fix’, which inks a user entry in the sys.database_principals system catalog view in the current database to a SQL Server login of the same name.

This code will fix all users in the database that you are executing the SQL code. (I use this very often)