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

3m read timeFrom bartwullems.blogspot.com
Post cover image
Table of contents
The setupWhat's actually happeningThe fixWhy does SQL Server do this?

Sort: