What can I do with a SQL Server diagram - sql-server

I created a SQL Server diagram in SSMS. This feature looks really great, but what can I do with it? :)
It's nice to have some kind of documentation, and it's nice that you can change a field within the diagram and this will have an effect on the actual table. But what are other reasons to create a diagram?
Is it possible for example to import a full diagram in any reporting tool? I noticed that the diagram is stored in a table which has a binary column in it with a long string. Can I copy/paste this in any other diagram tools?
Thanks in advance

I have never succeeded in importing into other tools. I tried pasting it into Visio (2007) but I could not edit the object in Visio, Notice you can control how the pages are printed (Right click on the surface area and select show page breaks - you can drag the page breaks) so that each printed page contains one or more complete tables. You can use the diagram to creating indexes and foreign key relationships. I have printed out the main tables and taped it to my desk while working on a project.

Related

SQL - Export Database Diagram - SSMS 17

I am trying to export 3 database (DB) diagrams from one DB to another using SSMS 17. I have tried the solution suggested here:
How to export a SQL Server 2008 Database Diagram to another DB?
This solution is also recommended in several other websites I have found so far, to copy the content of the table "sysdiagrams" from the source DB to the destination DB (3 rows in my case).
After doing this I can confirm that both "sysdiagrams" tables have the same content and the diagrams are imported in the destination DB. Nevertheless in each imported diagram I see only the tables but not the relationships. What I find strange is that the relationships are shortly visible while the tables in the diagram are being loaded. After all tables are loaded they just dissappear.
Does anyone know what the issue could be? It is my understanding, that this solution is successful for early versions of SSMS.
Any help is highly appreciated :) !
Check that the relations (Foreign Key constraints) actually exist in the target database, because if they don't then the diagram editor will behave exactly as you describe: initially it will draw all lines, then it starts looking for each FK relation that each line represents, and it will one by one remove lines for which relations are not found.
To clarify, you can create FK relations using the Diagram Editor by drawing a line between to tables (the editor then creates both a line in the diagram and the actual FK constraint). But with a 'copy diagram' action like yours, you copy only the line data but not the actual relations.
To add the missing relations in the target database you could write ALTER TABLE ... ADD CONSTRAINT ... statements, or use the Diagram Editor again on the target database, or you can try using a database diff tool.

How do I update a database Diagram in Microsoft SQL Server Management Studio

I currently have the database diagram window open in Microsoft Server Management Studio 2014. Is there a way to "refresh" the view so that I can see a newly added foreign key constraint?
Close the diagram. Right click on the diagram name under the "Database Diagrams" node on the tree to the left and select "Refresh", then re-open the diagram. That worked for me when I was trying to get the new fields, updated field names, and updated "nullable" values to display. It also didn't scramble the custom layout I did in the diagram, which I was afraid might happen. If your diagram is missing entire tables, then open the diagram, right click in the diagram's blank space, and select "Add Table" to add missing tables.
This was the first result that came up when I was trying to figure out how to refresh the tables to reflect new fields and such. I was hoping I wouldn't have to delete/re-add each table one-by-one!
It looks like the best way is to right click on the diagram and choose "remove table from diagram". Then right click in the white space and choose "Add Table". It will then show newly created relationships.

sql management studio 2012 diagram

I am creating a database diagram in SQL management studio 2012. In the picture for example these tables are linked by Subscriber_id, but if you move the table diagram the line is also moved. So you don't know see the joining key.
How can I make the line statically connected to both keys no matter where you move the table diagram. Please see example.
The link represents the join between the tables, not the fields. If you inspect the link you should see the actual join details.
If you right click on one of the tables you can select to view the relationships. You can also show the relationship names which indicates the nature of the relationship.
I'm not aware of anything in SSMS to print the detail you require, but if you have access to VS and Entity Framework you can generate an entity diagram that shows the navigation properties. This can be printed.

Database diagram connectors (SSMS 2012)

When creating a SSMS database diagram, I can click and drag to link two columns together. I can also move the connectors along the edges of the diagram.
The problem is that SSMS places the connectors table-to-table instead of column-to-column. This makes it hard to indicate at-a-glance exactly which columns are being linked, and if I place the connectors manually, they all get rearranged if I move the table. Is there any way to "snap" the connector to a column, or even any location on the table diagram?
I do not believe the database diagram connectors in SSMS work this way, but you can request/suggest new features here: https://connect.microsoft.com/SQLServer/Feedback

Is SQL Server Management Studio as bad as it seems? How to view relatiosnip attributes?

So, I'm using SQL Server Management Studio Express,it has been working not bad so far, ignoring some of the weirdness.
But I just happened to get a whole shwack of data deleted when I happened to delete a row in a parent table. So I thought I must have cascade deletes enabled in this relationship. But, how does one determine this?? If you double click a relationship in the DB Diagram, your only option is Delete, and the tooltip only shows you the FK relationship name.
This fellow had the same problem as me:
http://social.msdn.microsoft.com/forums/en-US/sqldatabaseengine/thread/1f9c1e8f-b719-476d-828e-91ac6722096a/
So, am I missing something, or is this another situation where a software company deliberately does a half assed job? I have an MSDN ultra (or whatever the highest level is) license, so will that be better, or, is there a 3rd party tool one can use??
In SQL Server Management Studio Express, don't you have the option to 'design' the table. (Right click on the table, then design) ?
Then, you should have an additional toolbar with an icon which looks like 3 tables and their relationships. The tooltip of that button says 'Relationships'.
When you click that button, you'll see the foreign key constraints of that table, and in the dialog box, you can specify the UPDATE & DELETE rules of the FK.
The diagram tool isn't great.
If you use the Object Explorer to open the Tables, open the table you're interested in, open Keys, you should be able to find your foreign key, right click on it and choose Modify (or choose to script it out (to window/file/etc)).
This works in SSMS 2008, haven't tried in 2005 Express, but I'd be surprised if it wasn't there (since it's basically functionality that was built into Query Analyser long ago)

Resources