SQL Interview: 64 Disabling and reenabling constraints

SQL Interview: 64 Disabling and reenabling constraints

This is a post in the SQL Interview series. These aren’t trick or gotcha questions, they’re just questions designed to scope out a candidate’s knowledge around SQL Server and Azure SQL Database.

Section: Administration Level: Medium

Question:

You have a table called Sales.Transactions that has an associated foreign key constraint. The constraint checks that CustomerID values correctly reference the CustomerID primary key of the Sales.Customers table.

You need to bulk load some transaction data and decide to disable the constraint during the load, hoping it will increase performance of the load.

After the load is complete, you enable the foreign key constraint again usign the following code:

ALTER TABLE Sales.Transactions
CHECK CONSTRAINT FK_Sales_Transactions_Sales_Customers;

When you reenabled the foreign key constraint, did it check the bulk loaded data?

Answer:

No. The foreign key constraint would be flagged as non-trusted.

2025-07-19