To copy database diagrams from database dbA to database dbB, run the following in the Query Analyser:
INSERT INTO dbB.dbo.sysdiagrams
SELECT[name],[principal_id],[version],[definition]
FROM dbA.dbo.sysdiagrams
--SELECT * FROM dbB.dbo.sysdiagrams
[Thanks to Pankaj Saha, a colleague at work, for this code snippet.]
Edit: This also works for SQL Server 2008.
Edit: This also works for SQL Server 2012, Service Pack 4.
Edit: Some other links that could be useful:
http://stackoverflow.com/questions/3310137/sql-server-2005-how-to-copy-a-database-diagram-to-another-server
If you get an error "Cannot insert the value null into column "diagram_id"", check this out: http://social.msdn.microsoft.com/Forums/en-US/sqldocumentation/thread/767de035-5509-4150-af21-8b6752653f05
INSERT INTO dbB.dbo.sysdiagrams
SELECT[name],[principal_id],[version],[definition]
FROM dbA.dbo.sysdiagrams
--SELECT * FROM dbB.dbo.sysdiagrams
[Thanks to Pankaj Saha, a colleague at work, for this code snippet.]
Edit: This also works for SQL Server 2008.
Edit: This also works for SQL Server 2012, Service Pack 4.
Edit: Some other links that could be useful:
http://stackoverflow.com/questions/3310137/sql-server-2005-how-to-copy-a-database-diagram-to-another-server
If you get an error "Cannot insert the value null into column "diagram_id"", check this out: http://social.msdn.microsoft.com/Forums/en-US/sqldocumentation/thread/767de035-5509-4150-af21-8b6752653f05
8 comments:
Great! Was looking for this, and it took me awhile to find it for sql 2005 diagrams. Thank you.
But First, if you don't have any Diagrams, table [sysdiagrams] is missing. In order to have this table click on the item [Database Diagram] corresponding to your source Database and SQL Management Studio will make this table for you.
Thank you for this tip.
Thanks for the post.
Steve Boyd
:( I get Failure inserting into the read-only column "diagram_id".
Check this out: http://social.msdn.microsoft.com/Forums/en-US/sqldocumentation/thread/767de035-5509-4150-af21-8b6752653f05
The question I'm going to ask is not of a relevance here. Could this be represented in a database diagram? Or any other database software to design database diagrams.
Could you elaborate Shalin? I don't understand your question.
Post a Comment