brandonmartinez

Temporarily Disable All T-SQL Table Constraints in a Database

After generating a set of scripts to import production data to a local development database, I ran into an issue with constraints blocking the inserts (this is on a fresh database structure). To get around the issue, execute this T-SQL command on your database:

EXEC sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all"

You can now insert data without constraints blocking the action. Once you’ve finished the import, you can re-enable all constraints using this command:

EXEC sp_msforeachtable "ALTER TABLE ? WITH CHECK CHECK CONSTRAINT all"

And please, don’t use this on a production database! Development or testing only!

One more tip: if you see the following error, you’ve most likely inserted data that violates one of your constraints. Check to make sure all of your inserts have succeeded.

The ALTER TABLE statement conflicted with the FOREIGN KEY constraint "FK_YOUR_FOREIGN_KEY_CONSTRAINT".

Facebook Email Addresses Now (Mostly) Defunct

A few years ago Facebook launched its anti-email campaign, saying that the future of messaging is no longer email. As of today (for me at least), they are no longer pushing emails sent to @facebook.com addresses into their messaging system.

FacebookEmailDefunct

Either they’ve achieved their goal of their messaging system being ubiquitous, or they finally decided to give up on the integration.

Toy Hack: Kidoozie Deluxe Build-a-Road With Elevator

One of the best things about being a parent? You get to play with some awesome kid-toys again! Seth received the a Kidoozie Build A Road X-Track set as a Christmas gift. We love building different tracks, finding different obstacles to integrate with the road, and just beings kids (at-heart, in my case).

Kidoozie Build A Road X-Track (Amazon.com)

After having such a blast with that set, I decided to pick up the deluxe expansion from Amazon. However, while the set provided some cool additions, there was something about it that was bothering me: the multi-directional gates required manual intervention or you’d never reach the full track. Continue reading…

Page 1 of 2812345...1020...»
Copyright © 2006 – 2014, Brandon Martinez. All rights reserved. A Martinez Media site.