Link to home
Start Free TrialLog in
Avatar of fcx
fcx

asked on

How to Export Database Diagrams to T-SQL script file

How can I reliably export a database diagram to a TSQL script file?  More specifically, how can I tell which rows in the dtproperties table are for which diagram?  I don't want to blindly copy the whole dtProperties table because I don't want to overwrite everything in the destination server.  Also I have tried this and it didn't work for me.  I see the diagram listed under the Diagrams node, but when I tried to open one of them I get an error about being out of memory.
Avatar of Anthony Perkins
Anthony Perkins
Flag of United States of America image

Avatar of fcx
fcx

ASKER

Thank you.  That script may prove to be valuable, but right now I cannot use it because I am trying to update a local dev server from a disconnected production server.  

I just using a DTS package to export the table to a flat file and then import the text file into the dev server, but this didn't work.  I got 'an unexpected error' message when I tried to open the diagram.

Do you know what is causing the failure?
No idea, I am afraid.
"I just using a DTS package to export the table to a flat file and then import the text file into the dev server, but this didn't work.  I got 'an unexpected error' message when I tried to open the diagram."

Probably because it's binary data and you exported it to a text file...
Avatar of fcx

ASKER

How should I be doing it then?  
I assumed the DTS package would do something appropriate with the binary data.  Looking at the file, I see plain text and Hex, not binary jibberish.
"Looking at the file, I see plain text and Hex, not binary jibberish."

Don't you see the column that has the format of "image"?  This is definately a binary column.

The way diagrams should be handled is from a backup/restore or a detach/attach--they are an integral part of the database and shouldn't be moved on their own.
Avatar of fcx

ASKER

I understand the data is ultimately binary, but it looked to me like the dts package translated the binary data into plain text (by way of hex value) like you would do to send a picture to someone through email.

So you're telling me there's no way to export a diagram to a disconnected database containing the same table structure?
SOLUTION
Avatar of arbert
arbert

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
But as arbert has mentioned, this is totally unsupported, so I recommend you backing up your server, prior to using it.
Avatar of fcx

ASKER

Thanks for your insight, arbert and acperkins.