Look up any SQL Server error by number: the cause, examples, fixes and prevention.
Common errors 21
2627
Violation of PRIMARY KEY / UNIQUE constraintCannot insert a duplicate key into a primary key or unique constraint.
547
Statement conflicted with a FOREIGN KEY or CHECK constraintAn insert, update or delete broke a foreign key or check rule.
18456
Login failed for userAuthentication failed; the state number reveals the real reason.
4060
Cannot open database requested by the loginThe requested database is missing, offline or off-limits to the login.
53
A network-related or instance-specific error (server not found)The client could not reach a listening SQL Server instance.
26
Error locating server or instance specified (SQL Network Interfaces)The client could not resolve the named instance (SQL Server Browser, UDP 1434, wrong name).
207
Invalid column nameThe query references a column that does not exist in scope.
208
Invalid object nameThe table, view or object cannot be resolved.
4104
The multi-part identifier could not be boundA table or alias prefix such as c.name does not match anything in the FROM clause.
209
Ambiguous column nameAn unqualified column name matches more than one table in the query.
8120
Column is invalid in the select list because it is not in an aggregate or GROUP BYA grouped query selects a column that is neither grouped nor aggregated.
137
Must declare the scalar variableA variable is used outside the batch or scope that declares it (GO, dynamic SQL).
245
Conversion failed converting varchar value to intA text value could not be converted to a number.
8152
String or binary data would be truncatedA value was too long for the column; the bare message used at compatibility level 140 or lower.
241
Conversion failed when converting date and/or time from character stringText could not be read as a date: placeholders, impossible dates or text + datetime.
1205
Transaction was deadlocked and chosen as the victimTwo transactions blocked each other; one was rolled back to break the cycle.
9002
The transaction log for database is fullThe log file cannot grow or reuse space, so writes stop.
3201
Cannot open backup device (operating system error)BACKUP or RESTORE could not open the file; the OS error says why (path, permission, device).
3154
The backup set holds a backup of a database other than the existing databaseRESTORE refused to overwrite an existing database that the backup was not taken from.
3159
The tail of the log for the database has not been backed upRestoring over a FULL recovery database would lose changes since the last log backup.
3013
BACKUP DATABASE / RESTORE DATABASE is terminating abnormallyThe closing line of every failed BACKUP or RESTORE; the real cause is the error printed just before it.
Constraint & Integrity 5
2627
Violation of PRIMARY KEY / UNIQUE constraintCannot insert a duplicate key into a primary key or unique constraint.
2601
Cannot insert duplicate key row with unique indexA duplicate value broke a unique index (the index version of 2627).
547
Statement conflicted with a FOREIGN KEY or CHECK constraintAn insert, update or delete broke a foreign key or check rule.
515
Cannot insert the value NULL into a NOT NULL columnA required column was left NULL and has no default value.
1785
Introducing FOREIGN KEY may cause cycles or multiple cascade pathsA cascading foreign key (CASCADE or SET NULL) would create a second cascade path or a cycle.
Logins & Permissions 19
18456
Login failed for userAuthentication failed; the state number reveals the real reason.
4060
Cannot open database requested by the loginThe requested database is missing, offline or off-limits to the login.
4064
Cannot open user default databaseThe login default database cannot be opened, so the connection fails.
229
The permission was denied on the objectThe user lacks SELECT, EXECUTE or another object-level permission.
262
Permission denied, unable to run a statementThe user cannot run CREATE, ALTER or another statement-level command.
15247
User does not have permission to perform this actionA security statement such as CREATE USER, CREATE ROLE or CREATE SCHEMA needs a permission the user lacks.
18452
Login failed: the login is from an untrusted domainWindows credentials could not be validated: untrusted domain, SPN or Kerberos/NTLM failure.
916
The server principal is not able to access the database under the current security contextThe login or impersonated user has no user (and no guest access) in the target database.
300
Permission was denied on object (for example VIEW SERVER STATE)A login lacks VIEW SERVER STATE or another permission a DMV or tool checks.
15023
User, group or role already exists in the current databaseThe user or role name is taken, often by an orphaned user after a restore.
15138
The database principal owns a schema and cannot be droppedDROP USER or DROP ROLE fails because the principal still owns a schema; transfer it with ALTER AUTHORIZATION.
15151
Cannot find the login or user because it does not exist or you do not have permissionA user, login, role or schema name was not found in this scope, or the caller lacks permission to change it.
15434
Could not drop login as the user is currently logged inDROP LOGIN is refused while any session (including pooled connections) uses the login.
18461
Login failed: server is in single user modeThe instance was started with -m and its only connection is already taken.
18470
Login failed: the account is disabledThe password was correct but the login is disabled.
18486
Login failed because the account is currently locked outA SQL login was locked by the Windows lockout policy after too many wrong passwords.
18487
Login failed: the password of the account has expiredA SQL login with CHECK_EXPIRATION has a password older than the maximum password age.
18488
Login failed: the password of the account must be changedThe login is flagged MUST_CHANGE and must set a new password before it can connect.
17809
Could not connect because the maximum number of user connections has been reachedA new connection was refused because the instance holds as many user connections as it allows; look for connection leaks first.
Connectivity 9
53
A network-related or instance-specific error (server not found)The client could not reach a listening SQL Server instance.
10061
TCP Provider: target machine actively refused itThe machine was reached but nothing accepted TCP connections on that port.
40615
Cannot open server requested by the login (Azure firewall)Azure SQL blocked the client IP address at the firewall.
26
Error locating server or instance specified (SQL Network Interfaces)The client could not resolve the named instance (SQL Server Browser, UDP 1434, wrong name).
40
Could not open a connection to SQL Server (Named Pipes Provider)The Named Pipes provider could not open the instance pipe; the Windows code after it says why.
233
No process is on the other end of the pipe (client error)The server closed the Shared Memory or Named Pipes connection during login.
10054
An existing connection was forcibly closed by the remote host (client error)The TCP connection was reset during the pre-login or TLS handshake.
10060
A connection attempt failed because the connected party did not properly respondThe TCP connection got no answer at all, usually a firewall dropping packets or a wrong address.
258
The wait operation timed out / execution timeout expired (client error)The client stopped waiting for a connection or a query (connection or command timeout).
Syntax & Object Resolution 22
102
Incorrect syntax nearThe parser hit an unexpected token in your T-SQL.
156
Incorrect syntax near the keywordA reserved keyword was used or placed where it is not allowed.
207
Invalid column nameThe query references a column that does not exist in scope.
208
Invalid object nameThe table, view or object cannot be resolved.
201
Procedure or function expects a parameter which was not suppliedA required stored procedure parameter was not passed.
4104
The multi-part identifier could not be boundA table or alias prefix such as c.name does not match anything in the FROM clause.
3701
Cannot drop the object because it does not exist or no permissionA DROP failed on a missing object or without the right permission.
209
Ambiguous column nameAn unqualified column name matches more than one table in the query.
8120
Column is invalid in the select list because it is not in an aggregate or GROUP BYA grouped query selects a column that is neither grouped nor aggregated.
105
Unclosed quotation mark after the character stringA string literal was opened but never closed, usually followed by error 102.
137
Must declare the scalar variableA variable is used outside the batch or scope that declares it (GO, dynamic SQL).
2714
There is already an object named in the databaseA CREATE or SELECT INTO uses a name already taken by a table, constraint or module.
213
Column name or number of supplied values does not match table definitionAn INSERT without a column list supplies the wrong number of values.
544
Cannot insert explicit value for identity column when IDENTITY_INSERT is OFFAn INSERT lists the identity column but IDENTITY_INSERT is not ON in this scope.
8101
An explicit value for the identity column can only be specified with a column list and IDENTITY_INSERT ONAn INSERT without a column list supplies a value for the identity column.
2812
Could not find stored procedureEXEC names a procedure that does not exist in that schema or database.
134
The variable name has already been declaredThe same @variable is declared twice in one batch or procedure; loops and IF blocks are not separate scopes.
2760
The specified schema name either does not exist or you do not have permissionA CREATE or SELECT INTO names a schema that is missing or that the user cannot ALTER.
4121
Cannot find either column or the user-defined function or aggregateA prefix.Name(...) call matched no function in that schema: wrong schema, alias as prefix, or an xml method on text.
4145
An expression of non-boolean type specified where a condition is expectedWHERE, IF or CASE WHEN got a value such as a bit column instead of a comparison.
4902
Cannot find the object because it does not exist or you do not have permissionsALTER TABLE names a table that does not resolve: a typo, the wrong schema, or a temp table from an ended scope.
1919
Column is of a type that is invalid for use as a key column in an indexA (max), text or image column was used as an index or constraint key; use INCLUDE, a hash or prefix column, or a shorter type.
Data Type & Conversion 15
245
Conversion failed converting varchar value to intA text value could not be converted to a number.
8114
Error converting data type X to YA value could not be converted to numeric, decimal, float or bigint, often through a procedure parameter.
8115
Arithmetic overflow converting expression to data typeA value was too large for the target numeric type.
8134
Divide by zero error encounteredAn expression divided by zero.
512
Subquery returned more than 1 valueA scalar subquery returned more than one row.
8152
String or binary data would be truncatedA value was too long for the column; the bare message used at compatibility level 140 or lower.
2628
String or binary data would be truncated (named column)The detailed truncation message (compatibility level 150 or higher) naming the table, column and truncated value.
241
Conversion failed when converting date and/or time from character stringText could not be read as a date: placeholders, impossible dates or text + datetime.
242
The conversion of a varchar data type to a datetime data type resulted in an out-of-range valueDay and month read in the wrong order (DATEFORMAT/language) or a date outside the datetime range.
220
Arithmetic overflow error for data type, valueA value did not fit tinyint or smallint; the message shows the value.
468
Cannot resolve the collation conflictTwo text columns with different collations were compared, joined or combined in a UNION.
206
Operand type clashTwo types with no implicit conversion met: int into a date column, datetime2 + 1, or the wrong table type for a TVP.
402
The data types are incompatible in the operatorAn operator such as = or + got types it cannot combine: text/ntext/xml compared with a string, or a string + uniqueidentifier.
8116
Argument data type is invalid for argument of functionA built-in function got the wrong type in one argument, such as SUBSTRING on an int or DATEADD with a varchar number.
8169
Conversion failed when converting from a character string to uniqueidentifierText that is not a valid GUID (a placeholder, an empty string, missing hyphens) was converted to uniqueidentifier.
Transactions 5
3930
The current transaction cannot be committed (doomed transaction)An error doomed the transaction; check XACT_STATE() and roll back before writing.
266
Transaction count after EXECUTE indicates a mismatching number of BEGIN and COMMITA procedure left a transaction open or ended its caller's transaction.
3902
The COMMIT TRANSACTION request has no corresponding BEGIN TRANSACTIONCOMMIT ran with no open transaction, usually after an earlier rollback.
3903
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTIONROLLBACK ran with no open transaction, often in a CATCH block or after a procedure or XACT_ABORT already rolled back.
6401
Cannot roll back; no transaction or savepoint of that name was foundROLLBACK named an unknown savepoint or an inner transaction; nothing was rolled back and the transaction is still open.
Log & Storage Space 3
9002
The transaction log for database is fullThe log file cannot grow or reuse space, so writes stop.
1105
Could not allocate space because the filegroup is fullA data file or filegroup ran out of room for new pages.
1101
Could not allocate a new page because the filegroup is fullA filegroup is full and cannot grow, so a new page could not be allocated (the object-less twin of 1105).
Backup & Restore 15
3201
Cannot open backup device (operating system error)BACKUP or RESTORE could not open the file; the OS error says why (path, permission, device).
3241
The media family on device is incorrectly formedThe restore file is not a readable backup: not a backup, cut short in transit, or an unreadable format.
3154
The backup set holds a backup of a database other than the existing databaseRESTORE refused to overwrite an existing database that the backup was not taken from.
3159
The tail of the log for the database has not been backed upRestoring over a FULL recovery database would lose changes since the last log backup.
3101
Exclusive access could not be obtained because the database is in useRESTORE needs the database to itself but other sessions are still connected.
3169
The database was backed up on a server running an incompatible versionThe backup comes from a newer SQL Server version and cannot be restored on this one.
4214
BACKUP LOG cannot be performed because there is no current database backupA log backup was attempted before a full backup started the log chain.
3013
BACKUP DATABASE / RESTORE DATABASE is terminating abnormallyThe closing line of every failed BACKUP or RESTORE; the real cause is the error printed just before it.
3117
The log or differential backup cannot be restored because no files are ready to roll forwardA log or differential restore after the database was already recovered (WITH RECOVERY is the default).
3156
File cannot be restored to the location; use WITH MOVERESTORE cannot create a database file at the path stored in the backup; give it a new path with MOVE.
3183
RESTORE detected an error on a page as read from the backup setA page in the backup failed checksum validation during RESTORE: the backup or its source is damaged.
4208
The statement is not allowed while the recovery model is SIMPLEBACKUP LOG on a database in SIMPLE recovery, where log backups do not exist.
4305
The log in this backup set begins at an LSN that is too recent to applyA log backup is missing from the restore sequence; restore the one that contains the LSN named.
1834
The file cannot be overwritten because it is being used by another databaseRESTORE would write a file to a path another attached database uses; restore WITH MOVE to new file names.
3203
Read on the backup device failedThe backup file was opened but could not be read to the end: a truncated copy, a damaged transfer or failing media.
Database State & Recovery 13
945
Database cannot be opened due to inaccessible files or insufficient memory or disk spaceA data or log file could not be opened, so the database is stuck in RECOVERY_PENDING.
926
Database cannot be opened; it has been marked SUSPECT by recoveryRecovery failed and the database was marked SUSPECT; find the cause in the error log and restore.
5120
Unable to open the physical file (operating system error)Attaching or starting a database could not open a file; the OS error says why (missing, access denied, locked).
5123
CREATE FILE encountered an operating system errorA new database file could not be created, usually because the service account cannot write to the folder.
3702
Cannot drop database because it is currently in useDROP DATABASE was refused because a session, often your own, is still using the database.
1813
Could not open new database; CREATE DATABASE is abortedAn attach opened the files but could not start the database; the error printed before 1813 says why.
3414
An error occurred during recovery, preventing the database from restartingRecovery failed at startup and the database was marked SUSPECT; fix the earlier logged error or restore.
5030
The database could not be exclusively locked to perform the operationA collation change or similar ALTER DATABASE needs exclusive access while other sessions are connected.
5173
One or more files do not match the primary file of the databaseAn attach listed a log or data file that belongs to another database or another copy.
9001
The log for database is not availableThe transaction log became unusable (storage, damage, TDE, log full); fix the earlier error and restart the database.
924
Database is already open and can only have one user at a timeThe database is SINGLE_USER and another session already holds its one connection.
942
Database cannot be opened because it is offlineThe database was set OFFLINE; find who did it and bring it back ONLINE.
922
Database is being recovered; waiting until recovery is finishedThe database is still in crash recovery after a restart, restore or ONLINE; wait and check progress.
Corruption & Consistency 8
824
SQL Server detected a logical consistency-based I/O errorA page read from disk failed its integrity check: a storage problem that needs a restore.
823
The operating system returned an error during a read or write (I/O error)Windows reported a failed read or write of a database file: a storage problem to fix before restoring.
825
A read of the file succeeded after failing (read-retry warning)A read only succeeded after retrying: an early warning of failing storage that no query reports.
2570
Column value is out of range for its data type (data purity)DBCC found a stored value that is illegal for its data type; DBCC repair cannot fix it, so correct the rows yourself.
601
Could not continue scan with NOLOCK due to data movementA NOLOCK or READ UNCOMMITTED scan lost its place as rows moved; use snapshot isolation instead of dirty reads.
605
Attempt to fetch logical page failed; it belongs to a different allocation unitA page belongs to another allocation unit: corruption at severity 21, a transient NOLOCK read at severity 12.
829
Page is marked RestorePendingA query touched a page whose page restore is not finished; complete the log restore sequence.
8921
Check terminated: a failure was detected while collecting factsDBCC CHECKDB stopped before checking anything, usually for lack of tempdb space or because system tables are damaged.
Memory 6
701
There is insufficient system memory in resource pool to run this queryA query could not get memory in the named resource pool; the cause is usually elsewhere on the instance.
802
There is insufficient memory available in the buffer poolThe buffer pool is full and cannot grow; find what fills it before changing memory settings.
8645
A timeout occurred while waiting for memory resources to execute the queryA query timed out waiting in the memory grant queue; tune the queries holding large grants.
8651
The requested memory grant was not available in resource poolA query could not get its memory grant in the named pool; check grants, pool limits and memory pressure.
17803
There was a memory allocation failure during connection establishmentA new connection was closed because the server could not allocate memory for it; the instance as a whole is short of memory.
17890
A significant part of SQL Server process memory has been paged outInformational: Windows paged out over half of SQL Server committed memory, so performance drops; find the competing memory demand.
Query Processing & Performance 7
530
The maximum recursion has been exhausted before statement completionA recursive CTE went deeper than MAXRECURSION (default 100), or the data loops.
217
Maximum stored procedure, function, trigger or view nesting level exceededProcedures, functions or triggers called each other more than 32 levels deep.
1934
Statement failed because SET options have incorrect settingsQUOTED_IDENTIFIER, ANSI_NULLS or similar is wrong for a filtered index or indexed view.
1204
Cannot obtain a LOCK resource at this timeThe instance ran out of lock memory, usually one huge transaction holding millions of locks.
8622
Query processor could not produce a query plan because of the hintsHints such as FORCESEEK or HASH JOIN demand a plan that cannot exist for the query.
8623
The query processor ran out of internal resources and could not produce a query planOne statement is too complex or too large to optimise (huge IN lists, many tables or partitions).
8624
Internal Query Processor Error: could not produce a query planAn optimiser defect stops one statement from compiling; rewrite or simplify the query and apply the latest cumulative update.
High Availability 8
976
The target database is participating in an availability group and is not accessible for queriesA secondary replica does not allow reads, or data movement to it is suspended.
35250
The connection to the primary replica is not activeA secondary cannot reach the primary through the AG endpoint, so the join fails.
1418
The server network address cannot be reached or does not existThe mirroring endpoint address cannot be reached: port, firewall, endpoint state or permission.
1408
The remote copy of the database is not recovered far enough to joinLog backups taken on the primary after the full backup were not restored on the secondary before the join.
35206
A connection timeout has occurred on a previously established connection to an availability replicaError log entry: a replica missed pings for longer than the session timeout (network, load or RESOLVING).
983
Unable to access availability database because the replica is not PRIMARY or SECONDARYThe replica is RESOLVING during a failover or quorum loss, so its AG databases are offline.
19456
None of the IP addresses configured for the listener can be hosted by the serverNo listener IP address fits a public cluster network on the named server, so it cannot host the listener.
41131
Failed to bring availability group online; the operation timed outThe AG cluster resource did not come online in time, usually because the NT AUTHORITY\SYSTEM login or its permissions are missing.
SQL Server Agent 4
22022
SQLServerAgent is not currently running so it cannot be notified of this actionsp_start_job was called while the SQL Server Agent service was stopped.
14262
The specified job (or other object) does not existAn msdb Agent procedure got a job, schedule or other name or id that does not exist on this server.
14258
Cannot perform this operation while SQL Server Agent is startingA job or alert procedure ran while SQL Server Agent was still starting; retry once Agent is running.
14274
Cannot add, update or delete a job that originated from an MSX serverA multiserver (MSX) job was changed on a target server, or a fixed @job_id was passed to sp_add_job.
Linked Servers 7
7202
Could not find server in sys.serversA four-part name or OPENQUERY names a linked server that is not defined here.
7399
The OLE DB provider for linked server reported an errorThe linked server provider failed; the reason is the text after "reported an error."
7303
Cannot initialize the data source object of OLE DB provider for linked serverThe provider could not open its file, DSN or remote server; read the provider message.
7391
The provider was unable to begin a distributed transactionA transaction across a linked server needed MSDTC, which is stopped, closed to the network or blocked.
7411
Server is not configured for DATA ACCESS (or RPC)The linked server has rpc out (EXEC ... AT) or data access (OPENQUERY) switched off.
7416
Access to the remote server is denied because no login-mapping existsThe linked server has no mapping for your login and no default mapping for all logins.
7356
The OLE DB provider supplied inconsistent metadata for a columnA linked server provider described a remote column differently at compile time and at run time.
No errors match. Press Search to search full messages, or browse every error.