14

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?

Gareth
  • 19,080
LtDan
  • 151

4 Answers4

18

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.

leinad13
  • 597
4

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

mrosiak
  • 161
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.

Journeyman Geek
  • 133,878