Deletes Ignore Check Constraints

James Anderson shows that delete statements will ignore check constraints:

I know it sounds a bit odd but DELETE statements really do ignore table constraints. Running the code below in a test database will setup a test to prove this.

James gives a couple pieces of advice on how to implement this scenario if you find yourself needing to do something like this.

Related Posts

Discovering Composite Keys

John Morehouse shares some good information on composite keys, including a few scripts: As I started to work on this, my first thought was that it would be helpful to know how many tables had a composite primary key.  This would give me an idea on how many tables I was dealing with.  Thankfully, SQL […]

Read More

Cleaning Up Foreign Keys

Adrian Buckman looks at how to clean up untrusted foreign key constraints: SQL Server tracks untrusted Foreign keys in sys.Foreign keys with a column called is_not_trusted, there may be a number of reasons why a Foreign key may have become untrusted below are a couple of examples: Foreign key was disabled using the ‘NOCHECK’ option then re-enabled using […]

Read More


May 2016
« Apr Jun »