Michael J. Swart

May 10, 2010

Disowning Your Relatives

Filed under: SQL Scripts,SQLServerPedia Syndication,Technical Articles — Michael J. Swart @ 5:05 pm

Say that you’re a table, and you don’t want to refer to any parents or children using foreign keys (and vice versa).

There’s a script for that:

--drop fks coming in and out
SET @sql = '' 
SELECT @sql = @sql + N'ALTER TABLE ' + OBJECT_NAME(parent_object_id) +  N' DROP CONSTRAINT ' + name + N'; '
FROM sys.foreign_keys
WHERE 'TableName' IN (
EXEC sp_executesql @sql

Just remember to replace “TableName” with the name of the table.

Disclaimer: Take care guys!

May 7, 2010

SQL Self Portrait

Filed under: SQLServerPedia Syndication,Tongue In Cheek — Michael J. Swart @ 9:24 am

Something fun for Friday. I pulled out almost all the content for this post from the comment section of More images from the Spatial Results Tab.

The one thing that I learned (and might be news to you) is the reason that Microsoft’s spatial results tab has such bland faded colors. It turns out that these colors have a certain amount of transparency applied to them so on a white background, they seem faded. But this also means that overlapping colors are combined!

Overlapping colors

Overlapping colors in the Spatial Results Tab

And transparent colors means a larger palette to play with without using the more faded colors! So I first take this source photo:


I reduce the color depth to the colors in my palette:

Reduced colors

and with C# and the usual magic I get:

SQL Self Portrait (Click to embiggen)

SQL Self Portrait (Click to embiggen)

With only six “polygons”. For the curious, the query itself is here but I’m warning you, uncompressed it’s 260 kb and it takes some time to run.

Happy Friday

May 4, 2010

So let’s talk…

Filed under: Miscelleaneous SQL — Michael J. Swart @ 5:52 pm

Hey you! Yeah YOU! The you that’s reading this very text, I need you to do me a favor!
I’m collecting information for a blog post I’m in the middle of writing. I don’t want to spill the beans yet, but if you could take the time to answer the following questions, I’d appreciate it!

Powered by WordPress