SQL Server 2005 | Copy Database Diagrams

Next is the code to copy database diagrams from one database to another (tested on SQL Server 2005 and 2008)

use [DB_SOURCE_NAME]

DROP TABLE dbo.#tempsysdiagrams
–this will copy your database diagrams into a temporary table
select * into dbo.#tempsysdiagrams from sysdiagrams

use [DB_DESTINATION_NAME]

insert into sysdiagrams ([name],principal_id,version,definition)
select [name],principal_id,version,definition from dbo.#tempsysdiagrams where [name]=’DIAGRAM_NAME’

Happy Diagramming

Hello, nice to meet you

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Leave a Reply