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
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.