views:

168

answers:

3

Sometimes I am looking at complex SQL Server SQL statements and wondered if there's a tool which can represent the query into a graphical model.

For example:

You have a select query which joins (could be inner + left and right joins) with 10 tables. Is there a tool to take this query, represent the 10 tables graphically and draw the different joins as relationships? And better yet, if you modify the joins and conditions graphically, it automatically updates the generated sql.

Think of it like a reverse query builder. You start from the sql query and end at the model.

+1  A: 

It's not a perfect solution but you can always view the query execution plan.

Andrew Hare
+2  A: 

The Query Designer in Management Console is actually two-way. You can use it to draw your query graphically, or you can paste or type in your t-sql and it will show a graphic display.

Just open a query window, then hit Ctrl-Shift-Q or choose "Design Query in Editor" from the Query menu.

tnyfst
Nice feature, did not know it.. horrible code it generates though :-)
Brimstedt
I use SSMS a lot and didn't know it existed! I tried it and the thing always crashes even with the simplest queries when I start with the query. I see it starting to draw the tables and then the window disappears. I am using SSMS 2008 with SP1.
Abdu
Actually I had an error and it works now. Although the designer should catch any errors and not bomb like that.
Abdu
A: 

Though not exactly what you are asking for, the TSQL Script Explorer from ISpySQL.com will come close. Disclaimer, I'm part of ISpySQL.com. Rob Vallee

Rob Vallee