Jeg har fundet en fornuftig løsning. Problemet er, at Management Studio ikke kan vise mere end 65535 tegn for ikke-XML-data og ikke kan indstilles til at vise mere end 65535.
Se kode for dokumentation :)
Sikkerhedskopieringsscript:
-- 1. Read from DB, using XML to workaround the 65535 character limit
declare @definition varbinary(max)
select @definition = definition from dbo.sysdiagrams where name = 'ReportingDBDiagram'
select
'0x' + cast('' as xml).value('xs:hexBinary(sql:variable("@definition") )', 'varchar(max)')
for xml path('')
-- 2. Open the result XML in Management Studio
-- 3. Copy the result
-- 4. Paste this in backup script for @definition variable
Gendan script:
declare @definition varbinary(max)
set @definition = 0xD0CF -- Paste 0x0 value from Backup script
-- Create diagram using 'official' Stored Procedure
exec dbo.sp_creatediagram
@diagramname = 'ReportingDBDiagramCopy',
@owner_id = null,
@version = 1,
@definition = @definition