I would like to create a database diagram in SQL Server 2008 and have a View in the diagram. is there a way to do this?
-
No, but Microsoft BI's [Data Source View](http://stackoverflow.com/questions/36804928/is-there-a-way-to-visually-display-a-database-view-in-a-database-diagram) allows for this, and a whole lot more. – katzbatz Apr 26 '16 at 15:12
2 Answers
I don't think so. SQL Server Management studio allows only Tables to be included in the database diagram. If you have Microsoft Visio, you can use that to include the Views in your database diagram.
Download SQL Sentry Plan Explorer - this is a free app that significantly extends the built-in execution plan functionality in Management Studio. Also grab the Management Studio add-in (you'll have to re-start SSMS). Once installed, in SSMS, run the following query, with "Actual Execution Plan" turned on:
SELECT * FROM dbo.view;
Right-click the Execution Plan and choose "View with SQL Sentry Plan Explorer."
Once the plan is open in Plan Explorer, you can see the base tables that are referenced by the view (even if they are nested) on the Join Diagram tab in the lower pane.
Disclaimer: I work for SQL Sentry, but there are absolutely no strings attached.

- 272,866
- 37
- 466
- 490
-
Just so I understood the idea correctly, this app is about more advanced display of query plans, right? Because the OP is asking about diagrams, not plans. So your suggestion is a sort of workaround, am I correct? I'm mainly asking to make sure I haven't misunderstood the purpose of this tool. – Andriy M Aug 25 '11 at 18:50
-
@Andriy One of the features of the tool is that it can show you the join diagram for a plan, including the simple case such as the query I showed. Whether you want to call that an answer or a workaround is just semantics, I think. If it shows a visual diagram of the joins in the view, then I think it answers the question. The question was not "is there a tool that is solely dedicated to visually describing a view?" – Aaron Bertrand Aug 25 '11 at 18:53
-
1No, it wasn't, and thanks to one of the screenshots I found there I can now see what you mean. That is a great feature, for a free app too. Still I think that answers the question only partly. I understand the OP wants the views to be included into a complete database diagram, so as (probably) to show the relationships between the views' underlying tables in conjunction with other relationships in the database. – Andriy M Aug 25 '11 at 19:10
-
1Ok, I'll gladly admit that it only partly answers the question. Again, semantics. How are you propose to do this in Management Studio? The other answer mentions Visio. No problem with that, except Visio is expensive. It might be worth the cost, or it may be useful to use a free product with a little more work (e.g. write a query with the joins you want to illustrate in the diagram, and then open that plan). – Aaron Bertrand Aug 25 '11 at 19:12
-
I'm upvoting this answer anyway. The tool can still be helpful, especially when no other solution is possible at the time. – Andriy M Aug 25 '11 at 19:14