question

Oren Nitzan avatar image
Oren Nitzan asked

How do I create database diagrams through a script?

Hi; Is there a simple and smart why to do this? I whould like to ceate a db diagram through C# code or run ADO query, or use SMO if it is possible. Thanks

database-diagrams
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

mrdenny avatar image
mrdenny answered

I'm not sure in SMO gives you a way to do this or not. The database diagram is simply stored in the database in a table. It doesn't actually have anything to do with the operation of the database. It is used by the EM or SSMS (depending on your SQL version) to show you the foreign keys in the database and how they link together.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Oren Nitzan avatar image
Oren Nitzan answered

Hi mrdeny thanks for replying. So if i created a data base dinamically with SMO, and created all the tables i need, dinamically, with queries through ADO.Net. How do i create the diagrams?

For now, i craete the 'systable' like above, and insert the diagram data the same why. I get the (hard coded data) from the source data base by creating the diagrams, selectins all from 'sysdiagrams' and get the lond hexadecimal data of the definution column.

This solution is a simpler why then the use of the 'Tool_ScriptDiagram2005' stored procidure, that runs as the only solution (i saw) on the net.

Both of the solutions does not seem to me a the wright why.

Any ideas?

Thanks Oren.

10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.