Medium severityauthentication
Power BI Refresh Error:
15023
What does this error mean?
A CREATE USER or sp_adduser statement failed because a user or role with that name already exists in the target database.
Common causes
- 1Restoring a database backup to a new server — the database user exists in the backup but the server login SID does not match (orphaned user)
- 2Running a deployment script twice — the CREATE USER statement was not made idempotent
- 3A migration script attempts to create a user that was manually created beforehand
How to fix it
- 1Step 1: Check if the user is orphaned (exists in DB but has no matching server login): USE [yourdb]; EXEC sp_change_users_login 'Report';
- 2Step 2: Re-map the orphaned user to the existing server login: USE [yourdb]; ALTER USER [username] WITH LOGIN = [loginname];
- 3Step 3: If the user is not orphaned and you just need an idempotent script, wrap in a check: IF NOT EXISTS (SELECT 1 FROM sys.database_principals WHERE name = 'username') CREATE USER [username] FOR LOGIN [loginname];
Frequently asked questions
Official documentation: https://learn.microsoft.com/en-us/sql/relational-databases/errors-events/mssqlserver-15023-database-engine-error