我已经找到一个合理的解决方案。问题是Management Studio无法为非XML数据显示更多65535个字符,并且无法将其设置为显示超过65535个字符。
见用于文档代码:)
备份脚本:
-- 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
恢复脚本:
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
看看这里它的非常详细的描述你正在尝试做什么http://gursethi.blogspot.co.uk/2011/03/how-to-take-backup-of-database-diagrams .html –
你能澄清一下**你正在尝试备份什么?你说“我想从我的图表创建备份脚本”是否要在图表中保存_diagram_或_objects_? – Tony
你的链接不工作:404 - 找不到 –