SQL Server error 15025: The server principal already exists
CREATE LOGIN used a name (or SID) that already exists on the instance. Check for the existing login, or create it only if missing.
- Error number
15025- Severity
- 16
- Category
- Permissions
What it means
Login names are unique across the SQL Server instance, and so are login SIDs. Error 15025 appears when you create a login whose name, or the SID you specified to match another server, is already taken.
Common causes
- Re-running a script that creates logins.
- Copying logins between servers with
SID = ...when a login with that SID but a different name already exists. - A Windows login added again under a different spelling of the same account.
How to fix it
-
Check existing logins by name and SID.
SELECT name, sid, type_desc FROM sys.server_principals WHERE name = N'app_user';
-
Create the login only when it's missing.
IF SUSER_ID(N'app_user') IS NULL CREATE LOGIN app_user WITH PASSWORD = N'<strong password>';
Related errors
15023User, group, or role already exists15151Object doesn't exist or no permission1396MySQL: Operation CREATE USER failed
More permissions errors
916Login can't access the database229Permission denied on object262Permission denied in database15138User owns a schema, cannot be dropped
The code and message text are from the Microsoft Database Engine events and errors reference. Browse the full SQL Server error list or search every database error.
Work on SQL Server in SQLly
A native SQL client for macOS, Windows and Linux with schema-aware IntelliSense, guardrails for risky statements and clear error messages, for SQL Server and the other databases you use.