x

SSMS Execution Plan Art Work Challenge

My Principal DBA here has just set me a rather interesting challenge.

"Can you get it to draw a rude picutre ?" He was referring to the Execution plan pane in Sql Server Management Studio. I confessed my skills were not that good but offered to ask some REAL experts. So here I am asking "Are you able to write some code that generates an execution plan diagram that is a picture of something ?" I think it may be prudent to leave out the 'rude' part so we do not offend anyone.

Oh and incase you were wondering, we do have work to do here, honest!

more ▼

asked Jun 09, 2011 at 08:33 AM in Default

avatar image

megamanblue
310 7 6 11

A tree ???

Jun 09, 2011 at 08:40 AM Kev Riley ♦♦

@Kev Riley Anything goes imo. Just paste the query or a screenie (no photoshopping!)

Jun 09, 2011 at 08:59 AM megamanblue
(comments are locked)
10|1200 characters needed characters left

2 answers: sort voted first

How about a one sided christmas tree with sweary words in it? Just run the following, then when you are happy with the construction, uncomment the exec command:

 DECLARE @tsql nvarchar(max)
 DECLARE @swearyword nvarchar(255)
 
 SET @swearyword = '@stupidhead'
 
 -- make sure swearyword is correctly formed
 IF LEFT(@swearyword,1)<>'@'
  SET @swearyword = '@'+@swearyword
  
 -- build the string, forced loop join to shape the plan
 SET @tsql = '
 DECLARE '+@swearyword+' AS TABLE (col1 int)
 
 SELECT  *
 FROM    '+@swearyword+' T1
 INNER LOOP JOIN '+@swearyword+' t2 ON T1.col1 = t2.col1
 INNER LOOP JOIN '+@swearyword+' t3 ON t1.col1 = t3.col1
 INNER LOOP JOIN '+@swearyword+' t4 ON t2.col1 = t3.col1'
 
 PRINT @tsql
 --EXEC (@tsql)

You will always be constricted in the shapes you can construct because the query plan is pretty much always going to be a tree shape.

more ▼

answered Jun 09, 2011 at 09:22 PM

avatar image

WilliamD
26.2k 18 34 48

@WilliamD You certainly answered the question +1 from me.

Jun 10, 2011 at 04:24 AM megamanblue
(comments are locked)
10|1200 characters needed characters left

I have seen drawings created with spatial data by Alex Whittles as SQLBits which was very interesting - http://www.purplefrogsystems.com/blog/2011/05/sql-server-art-using-spatial-data/

more ▼

answered Jun 10, 2011 at 02:27 AM

avatar image

Fatherjack ♦♦
43.7k 79 98 117

I'll second that it was absolutely genius.

Jun 10, 2011 at 02:37 AM Mrs_Fatherjack

@Fatherjack I think I may have found a new hobbie... that is absolutely brilliant.

Jun 10, 2011 at 04:25 AM megamanblue

wouldnt be at all surprised if you could get quite a following :)

I remember Alex mentioned that the R2 data types will make better pictures as they support curves rather than straight lines so images will be move aesthetically pleasing. Because that matters in a database engine!!

Jun 10, 2011 at 04:32 AM Fatherjack ♦♦

It doesn't matter but it is good fun!

Jun 10, 2011 at 05:15 AM Mrs_Fatherjack

Surprised no one has posted a link to this one yet http://michaeljswart.com/2010/02/more-images-from-the-spatial-results-tab/

Jun 10, 2011 at 05:47 AM Martin 1
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.

Topics:

x1069
x428
x59
x11

asked: Jun 09, 2011 at 08:33 AM

Seen: 1755 times

Last Updated: Jun 09, 2011 at 08:33 AM

Copyright 2016 Redgate Software. Privacy Policy