SQL Server silently renames a database user to match the login name when you run ALTER USER ... WITH LOGIN without specifying a NAME. This breaks idempotent scripts: the first run renames the user, the second run can't find it and fails. The fix is to explicitly include WITH NAME = [original_username] in the ALTER USER
Sort: