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

后端 未结 6 1305
遇见更好的自我
遇见更好的自我 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:31

    You can get rid of the UPDATE statement by fixing your INSERT statement - specifically the select portion. You are inserting the diagram_id column into the principal_id column (diagram_id is an identity).

    Change it to:

    DECLARE @SourceDiagramId int = 1
    INSERT INTO [DestinationDB].[dbo].sysdiagrams
    SELECT [name],principal_id,version,definition from [SourceDB].[dbo].sysdiagrams
    WHERE diagram_id = @SourceDiagramId
    

    And presto, it's all in there right the first time.

提交回复
热议问题