brettr
asked on
Scripting out a Database Diagram
In sql server 2005, is it possible to script out a database diagram?
ASKER
I only mean scripting a database diagram. I've created new tables and linked olds within the diagram. I want that scripted out via the database diagram.
Still having trouble with the terminology.
If you want your database diagram scripted instead of just saved as data in dtproperties, then follow the link I pointed you to.
If you want your tables and relationships scripted, use other tools: either the ones that came with SQL server management studio that allow you to script objects in the database (tables, indexes and constraints etc) by right-clicking on a table or other object and choosing "script table as CREATE to..." or by using third party tools such as EMS SQL studio (my favorite) or red gate that let you script out an entire database in one command.
Let me know if I am still misunderstanding you.
Philippe
If you want your database diagram scripted instead of just saved as data in dtproperties, then follow the link I pointed you to.
If you want your tables and relationships scripted, use other tools: either the ones that came with SQL server management studio that allow you to script objects in the database (tables, indexes and constraints etc) by right-clicking on a table or other object and choosing "script table as CREATE to..." or by using third party tools such as EMS SQL studio (my favorite) or red gate that let you script out an entire database in one command.
Let me know if I am still misunderstanding you.
Philippe
ASKER
I'd like to save the diagram and then load it into a copy of the same database that does not have the diagram. This means the new tables and relations will need to be created. Is there a way to do that without going to each table and scripting it? After I change anything in the diagram, I have to go to each object and script them. That is what I'm trying to avoid until the diagram is finalized.
Is there a way to do that without running all of the scripts mentioned in the link you provided?
Thanks.
Is there a way to do that without running all of the scripts mentioned in the link you provided?
Thanks.
So are you asking:
Is there a way to transfer a SQL Server diagram for a database to another SQL Server database with an identical schema? If so check this out:
http://www.mssqlcity.com/FAQ/TranMove/MoveDiag.htm
Is there a way to transfer a SQL Server diagram for a database to another SQL Server database with an identical schema? If so check this out:
http://www.mssqlcity.com/FAQ/TranMove/MoveDiag.htm
I think the following process is what you are trying to do:
1. Create new objects using a database diagram (you've done this)
2. Copy the database diagram into a copy of the current database that does not have the objects
3. Have the diagram automatically create the missing objects in the database copy.
If so, you can't do that - but you can use one of the tools I indicated to compare the two database and automatically generate a set of scripts to bring over any changes.
Philippe
1. Create new objects using a database diagram (you've done this)
2. Copy the database diagram into a copy of the current database that does not have the objects
3. Have the diagram automatically create the missing objects in the database copy.
If so, you can't do that - but you can use one of the tools I indicated to compare the two database and automatically generate a set of scripts to bring over any changes.
Philippe
ASKER
@acperkins:
When I try to run just the select from the link you provide, I get:
Invalid object name 'mydatabase..dtproperties'
When I try to run just the select from the link you provide, I get:
Invalid object name 'mydatabase..dtproperties'
This message indicates that the dtproperties table is mising. If the dtproperties table doesn't exist that just means there have not been any diagrams created yet for the target database.
Philippe
Philippe
ASKER
There are two diagrams in the database I'm SELECTing on.
instead of mydatabase..dtproeprties try mydatabase.dbo.dtpropertie s, or replace "dbo" with the schema that the dtproperties table is in.
SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
Not sure what you mean by scripting out a database diagram? If you mean script out your database, yes, there are tools for that. If you mean turn the data normally stored in the dtproperties table into a set of insert/update statements, here is a link to an article about someone who did just that - although, considering that it is all binary data, you would probably be better off with a simple backup.
Here is the link:
http://www.codeproject.com/KB/database/ScriptDiagram2005.aspx
Hope this helps,
Philippe