How to export a SQL Server 2008 Database Diagram to another DB?

后端 未结 6 1320
遇见更好的自我
遇见更好的自我 2020-12-12 20:53

I use the handy Database Diagramming tool in SQL Server 2008 for creating and managing relationships. I have exported the sourceDB to the destinationDB but the diagram does

6条回答
  •  旧巷少年郎
    2020-12-12 21:48

    If the databases are in different servers, there may be permission issues.

    To copy the sysdiagrams, create the same number of "dummy" diagrams in the target server where you want to copy the diagrams, add the target server as a Linked Server in the source server and then run the script:

    SELECT * from [LINKEDSERVER].TARGETDB.[dbo].sysdiagrams
    SELECT * from SOURCEDB.[dbo].sysdiagrams
    
    update [LINKEDSERVER].TARGETDB.[dbo].sysdiagrams set definition=
    (SELECT definition from SOURCEDB.[dbo].sysdiagrams WHERE diagram_id = 1)
    where diagram_id=1 
    -- the first 2 select commands will confirm that you are able to connect to both databases
    -- then change the id as required to copy all the diagrams
    

提交回复
热议问题