Query troubleshooting

SQL Errors

Find what is going wrong in your query and jump straight to the cause and the fix.

33 errors to work through

Browse by symptom

Browse by symptomAll

33 results

The query will not run

7

Missing rows

4

Extra rows appear

3

GROUP BY and calculations

6

INSERT, UPDATE, DELETE and schema

8
CHECK rejects the valueThe value makes one of the table's CHECK conditions false. Fix the data, or review the business rule before you change the constraint. DROP COLUMN fails due to dependenciesThe column is still used by indexes, views or constraints. Identify each dependency and change or remove only the ones that need it before dropping the column. The text does not fit in VARCHARThe value exceeds the defined limit, or the unit the engine measures it in. Fix the data if it is invalid; widen the column with a migration if the value is legitimate. FOREIGN KEY blocks an insert or deleteThe child reference has no parent, or you are trying to delete a parent that is still referenced. Check the key and the load order; before deleting, look at the child rows and the action defined on the key. INSERT has a different number of columns and valuesEach VALUES row needs one value for every column listed in the INSERT. Line up both lists, or drop the column that should get its DEFAULT from the target list. NOT NULL rejects a missing valueA required column receives NULL from an insert, update or transformation. Fix the source of the data; leave the column out only when a valid DEFAULT exists. UNIQUE rejects a duplicate valueA row already exists with the value or combination that must be unique. Find that row and decide whether to update it, ignore the duplicate or fix the incoming data. UPDATE or DELETE modifies too many rowsThe statement does not limit which rows should change. Test the same filter with SELECT and rehearse the change in a transaction you can roll back before you COMMIT.

Subqueries and set operations

4

Locks and concurrency

1