13

In SQL Server Management Studio, I have relationships set up between tables.

Is there a way to display a view of all the tables with the adjoining lines like in Microsoft Access? Do I need to open a new query and run something or is there a button that I've missed?

16

If you are using Management Studio 2008 :

Expand the root Database, try and expand the Database Diagrams folder, it should say something like "no diagrams".

If it asks you to create a diagram say yes, then add the tables and voila!

If not, right on Database Diagrams folder and create new Diagram.

3
  • 3
    That is very helpful, but I don't want to create a diagram, I want to see the current relationships between tables. If I create a diagram, it's just whatever I put on the diagram... – LtDan Jul 13 '11 at 20:11
  • 4
    If you create the diagram and add your tables, it automatically adds the relationships..... like in access. Try it – leinad13 Jul 14 '11 at 14:41
  • for me is not as no one table has Foreign keys – Dmitrij Holkin Jul 3 '20 at 13:34
5

Try out ApexSQL Search

ApexSQL Search is a FREE SQL Server Management Studio and Visual Studio add-in that, among other features, has the View Dependencies feature. The View Dependencies feature has the ability to visualize all SQL database objects’ relationships, including those between encrypted and system objects, SQL server 2012 specific objects, and objects stored in databases encrypted with Transparent Data Encryption (TDE)

The View Dependencies feature also allows you to set up and customize the visual dependencies diagram layout, including the relationships that will be presented, the layout and size of the generated diagram, and the drill-down depth of the dependencies

4

If you want to display dependencies for specific table just select your table and right-click View Dependencies. Check how to view dependencies.

SQL Server 2005 lets you display dependencies like this

SELECT OBJECT_NAME(object_id) referencing,
  OBJECT_NAME(referenced_major_id),
  *
FROM sys.sql_dependencies 

SQL Server 2008 has sys.sql_expression_dependencies follow this link

1
  • Great alternative! I'm working with a massive DB (1,500+ tables) that I absolutely do not want to generate a whole diagram for. This is great for getting a table-by-table view of relationships without having to process an entire DB worth of tables. – zcoop98 Feb 23 at 18:20
0

I am reading this question in 2015 and I am using SQL Server 2012. In this scenario, in order to view the dependencies of a table, you can follow these steps:
1. At the root folder of your database, there is a folder called Database Diagrams. Expand this database and click 'yes' in the pop up that is going to appear;
3. Right click the field that you suspect it has a dependency, normally they have the letters ID in their names, for example, I am in the EPM database and in the table MSP_Projects we have the field Proj_UID, right click the field;
4. In the context menu that appears, select the item Relationships. At the left site of the window you will see the foreign keys related with this primary key, and at the right side of the window you will see the properties of the existing relationship.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.