When you create database diagrams in Enterprise Manager, the details
for constructing those diagrams is saved into the dtproperties table.
This table includes an image field which contains most of the relevant
infomation, in a binary format.
SQL Enterprise manager offers no way to script out those diagrams, so
I have created two Transact SQL components, one User Function and one
User Procedure, which together provide a means to script out the
contents of the dtproperties table, including all of the binary based
image data, into a self documenting, easy to read script. This script
can be stowed away safely, perhaps within your versioning software,
and it can subsequently be recalled and executed to reconstruct all
the original diagrams.
The script is intelligent enough not to overwrite existing diagrams,
although it does allow the user to purge any existing diagrams, if
they so choose.
Once these two objects have been added to any database, you may then
backup (script out) the current database diagrams by executing the
stored procedure, like this:
Exec usp_ScriptDatab aseDiagrams
By default, all database diagrams will be scripted, however, if you
want to script the diagrams individually, you can execute the same
procedure, passing in the name of a specific diagram. For example:
Exec usp_ScriptDatab aseDiagrams 'Users Alerts'
The Transact SQL code for the two objects is too long to paste here,
but if you are interested, I will email it to you. Just drop me a note
at: clayTAKE_THIS_O UT@beattyhomeTA KE_THIS_OUT.com (Remove both
instances of TAKE_THIS_OUT from my email address first!!)
-Clay
for constructing those diagrams is saved into the dtproperties table.
This table includes an image field which contains most of the relevant
infomation, in a binary format.
SQL Enterprise manager offers no way to script out those diagrams, so
I have created two Transact SQL components, one User Function and one
User Procedure, which together provide a means to script out the
contents of the dtproperties table, including all of the binary based
image data, into a self documenting, easy to read script. This script
can be stowed away safely, perhaps within your versioning software,
and it can subsequently be recalled and executed to reconstruct all
the original diagrams.
The script is intelligent enough not to overwrite existing diagrams,
although it does allow the user to purge any existing diagrams, if
they so choose.
Once these two objects have been added to any database, you may then
backup (script out) the current database diagrams by executing the
stored procedure, like this:
Exec usp_ScriptDatab aseDiagrams
By default, all database diagrams will be scripted, however, if you
want to script the diagrams individually, you can execute the same
procedure, passing in the name of a specific diagram. For example:
Exec usp_ScriptDatab aseDiagrams 'Users Alerts'
The Transact SQL code for the two objects is too long to paste here,
but if you are interested, I will email it to you. Just drop me a note
at: clayTAKE_THIS_O UT@beattyhomeTA KE_THIS_OUT.com (Remove both
instances of TAKE_THIS_OUT from my email address first!!)
-Clay
Comment