Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / SQL

Backup SQL Diagrams In Less Than 5 Minutes

4.22/5 (8 votes)
16 Oct 2009CPOL2 min read 46.9K   429  
Import, export and move your SQL diagram around using sysdiagrams

Fancy Diagram

Introduction

Many times I had to generate databases from scripts, sometimes I use scripts to load data into tables but always I have the same problem with the diagrams, I keep losing them... you may also have this problem when using SQL Server on a shared hosting (most of the shared hosting companies will not grant you permissions for diagrams) so whenever you restore a copy of your online database, you lose your diagrams.

A good diagram is a key for understanding the data flow in a project. It could be a monster diagram with 20 pages and relationships that takes hours to prepare (by the way, you can also use copy and paste through your diagrams to modify and design your tables).

Anyway, my point is that using sysdiagrams (a system table used in SQL Server 2005 and above), you can very easily backup and restore your diagrams. Just keep in mind that you must have the database structure on your source and destination databases.

Using the Code

You can do it in less than 5 minutes (no kidding). The attached script refers to a sample Microsoft database named "AdventureWorks" that comes with SQL Server but you can easily apply it to any database. First make sure that your database can use diagrams.

You may need to set a database owner, do it from your Database Properties -> Files.

Database Properties

You may also need to click Yes (in order to create one or more support objects):

Create Support Objects

You can manually create new database diagrams or copy the existing ones (if any):

SQL
SELECT * FROM [dbo].[sysdiagrams] ORDER BY [name] ASC

Query Results

Copy the [definition] value from the query results (or any other diagram) and paste it to the INSERT script. (Please note that the value may seem empty, but copy it anyway and it will have a value when you paste it.)

SQL
Use AdventureWorks

-- Clear all diagrams (backup first)
-- DELETE FROM [dbo].[sysdiagrams]

-----------------------------------------------------------------------------------------
-- Create ExampleDiagram (all tables on which this diagram is based on must be in place)
-----------------------------------------------------------------------------------------
INSERT INTO [dbo].[sysdiagrams] ([name] ,[principal_id] ,[version] ,[definition])
VALUES
(
    'ExampleDiagram', 1, 1,
    0xD0CF11E0A1B11AE1000000000000000000000000000000003E000300FEFF090006000000000000_
    0000000000010000000100000000000000001000000200000001000000FEFFFFFF00000000000000_
    00FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFDFFFFFF130000_
    00FEFFFFFF0400000005000000060000001E00000008000000090000000A0000000B0000000C0000_
    000D0000000E0000000F000000100000001100000012000000FEFFFFFFFEFFFFFF15000000160000_
    001700000018000000190000001A0000001B0000001C0000001D000000FEFFFFFF1F000000FEFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF52006F006F007400200045006E0074_
    00720079000000000000000000000000000000000000000000000000000000000000000000000000_
    00000000000000000016000500FFFFFFFFFFFFFFFF02000000000000000000000000000000000000_
    00000000000000000000000000B025E1C5FA4DCA0103000000C00B00000000000066000000000000_
    00000000000000000000000000000000000000000000000000000000000000000000000000000000_
    000000000000000000000000000000000004000201FFFFFFFFFFFFFFFFFFFFFFFF00000000000000_
    000000000000000000000000000000000000000000000000000000000000000000D6060000000000_
    006F0000000000000000000000000000000000000000000000000000000000000000000000000000_
    00000000000000000000000000000000000000000000000000040002010100000004000000FFFFFF_
    FF000000000000000000000000000000000000000000000000000000000000000000000000070000_
    00DF16000000000000010043006F006D0070004F0062006A00000000000000000000000000000000_
    00000000000000000000000000000000000000000000000000000000000000000012000201FFFFFF_
    FFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000_
    00000000001C0000005F000000000000000100000002000000030000000400000005000000060000_
    000700000008000000090000000A0000000B0000000C0000000D0000000E0000000F000000100000_
    001100000012000000130000001400000015000000160000001700000018000000190000001A0000_
    001B000000FEFFFFFF1D000000FEFFFFFFFEFFFFFF20000000210000002200000023000000240000_
    0025000000260000002700000028000000290000002A0000002B0000002C0000002D000000FEFFFF_
    FFFEFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF_
    FFFFFFFFFFFFFFFFFF000430000A1E100C05000080110000000F00FFFF11000000007D0000C19B00_
    00EF6C0000A5A800004D85000078ECFFFF05F6FFFFDE805B10F195D011B0A000AA00BDCB5C000008_
    003000000000020000030000003C006B0000000900000000000000D9E6B0E91C81D011AD5100A0C9_
    0F5739F43B7F847F61C74385352986E1D552F8A0327DB2D86295428D98273C25A2DA2D0000280043_
    0000000000000053444DD2011FD1118E63006097D2DF4834C9D2777977D811907000065B840D9C00_
    002800430000000000000051444DD2011FD1118E63006097D2DF4834C9D2777977D811907000065B_
    840D9C11000000E40500000091010000003800A50900000700008001000000A20200000080000010_
    00008053636847726964005AF1FFFFEA240000437573746F6D6572202853616C6573290000A000A5_
    0900000700008003000000520000000180000076000080436F6E74726F6C006F1600004A0B000052_
    656C6174696F6E736869702027464B5F437573746F6D6572416464726573735F437573746F6D6572_
    5F437573746F6D65724944202853616C65732927206265747765656E2027437573746F6D65722028_
    53616C6573292720616E642027437573746F6D657241646472657373202853616C65732927000000_
    002800B50100000700008004000000310000007F00000002800000436F6E74726F6C00B518000012_
    17000000004000A50900000700008005000000B6020000008000001600008053636847726964006E_
    28000012FDFFFF576F726B4F72646572202850726F64756374696F6E29000000004000A509000007_
    00008002000000B4020000008000001700008053636847726964003C0F000012FDFFFF437573746F_
    6D657241646472657373202853616C6573290000003800A509000007000080060000009C02000000_
    8000000D00008053636847726964005AF1FFFF12FDFFFF53746F7265202853616C65732965732900_
    008C00A509000007000080070000005A0000000180000062000080436F6E74726F6C00EB060000A8_
    FDFFFF52656C6174696F6E736869702027464B5F53746F72655F437573746F6D65725F437573746F_
    6D65724944202853616C65732927206265747765656E2027437573746F6D6572202853616C657329_
    2720616E64202753746F7265202853616C65732927650000002800B5010000070000800800000031_
    0000006B00000002800000436F6E74726F6C00670C0000570E000000004800A50900000700008009_
    000000C0020000008000001F00008053636847726964005AF1FFFF1C3E00005472616E7361637469_
    6F6E486973746F7279202850726F64756374696F6E290000003C00A5090000070000800A000000AE_
    020000008000001400008053636847726964006E280000D020000050726F64756374202850726F64_
    756374696F6E290000B000A5090000070000800B000000620000000180000088000080436F6E7472_
    6F6C00DC200000FB20000052656C6174696F6E736869702027464B5F5472616E73616374696F6E48_
    6973746F72795F50726F647563745F50726F647563744944202850726F64756374696F6E29272062_
    65747765656E202750726F64756374202850726F64756374696F6E292720616E6420275472616E73_
    616374696F6E486973746F7279202850726F64756374696F6E292700002800B5010000070000800C_
    000000310000008100000002800000436F6E74726F6C00EE0D0000982E00000000A000A509000007_
    0000800D000000520000000180000076000080436F6E74726F6C00F12A00006B15000052656C6174_
    696F6E736869702027464B5F576F726B4F726465725F50726F647563745F50726F64756374494420_
    2850726F64756374696F6E2927206265747765656E202750726F64756374202850726F6475637469_
    6F6E292720616E642027576F726B4F72646572202850726F64756374696F6E2927000000002800B5_
    010000070000800E000000310000006F00000002800000436F6E74726F6C00372D0000CF1B000000_
    003C00A5090000070000800F000000AA020000008000001400008053636847726964005AF1FFFF56_
    13000041646472657373547970652028506572736F6E290000A800A509000007000080100000005A_
    0000000180000080000080436F6E74726F6C008A0400004A0B000052656C6174696F6E7368697020_
    27464B5F437573746F6D6572416464726573735F41646472657373547970655F4164647265737354_
    7970654944202853616C65732927206265747765656E202741646472657373547970652028506572_
    736F6E292720616E642027437573746F6D657241646472657373202853616C6573292700002800B5_
    0100000700008011000000310000008B00000002800000436F6E74726F6C0015100000C715000065_
    006C00650063007400610062006C006500063014000000730068006F007700730065006C00650063_
    000100FEFF030A0000FFFFFFFF00000000000000000000000000000000170000004D6963726F736F_
    66742044445320466F726D20322E300010000000456D626564646564204F626A6563740000000000_
    F439B271000000000000000000000000006100750074006F006C00610079006F00750074000A300E_
    000000670072006F00010002000000000000000C0000004E61BC00650064000B3009000000670072_
    006F00750070006E006F00640065000C3007000000740061006200730074006F00DBE6B0E91C81D0_
    11AD5100A0C90F5739000002006062E0C5FA4DCA0102020000104845000000000000000000000000_
    00000000008201000044006100740061002143341208000000AE300000A216000078563412070000_
    001401000043007500730074006F006D006500720020002800530061006C006500730029000000DF_
    7745F9DF7700000000010000000000000004DD1700213669760000500000000000602F4D093CDD17_
    00B6A1D7710000500000000000D2A1D7714A73F8A8CCDD170001000000000000003E73F8A8FC359E_
    7078DD1700D8CB2572FFFFFFFFD2A1D77100000000E800000084DD17008CA0D77100005000000000_
    00ABA0D771F273F8A814DE170001000000000000008CDD170051C4D77100000800C0DD1700F83924_
    72FFFFFFFFABA0D7710AA1D7710000500000000000E0000000CCDD170076F2D771B811140793F2D7_
    71BA73000000000000000000000400000005000000540000002C0000002C0000002C000000300000_
    0000000000000000009624000088160000000000002D010000080000000C000000070000001C0100_
    00BC07000054060000D0020000840300007602000038040000460500002A03000046050000AE0600_
    00920400000000000001000000151500006612000000000000060000000600000002000000020000_
    001C010000AB0900000000000001000000C7110000320C0000000000000400000004000000020000_
    00020000001C010000BC0700000100000000000000C7110000ED0300000000000000000000000000_
    0002000000020000001C010000BC0700000000000000000000AE300000A216000000000000000000_
    000D00000003000000030000001C010000B00400007305000078563412040000005E000000010000_
    00010000000B00000000000000010000000200000003000000040000000500000006000000070000_
    0008000000090000000A00000006000000530061006C006500730000000900000043007500730074_
    006F006D0065007200000002000B0006180000EA24000006180000050E00000000000002000000F0_
    F0F00000000000000000000000000000000000010000000400000000000000B5180000121700008F_
    180000580100003A0000000100000200008F18000058010000020000000000050000800800008001_
    000000150001000000900144420100065461686F6D61260046004B005F0043007500730074006F00_
    6D006500720041006400640072006500730073005F0043007500730074006F006D00650072005F00_
    43007500730074006F006D00650072004900440021433412080000004B150000141B000078563412_
    070000001401000057006F0072006B004F00720064006500720020002800500072006F0064007500_
    6300740069006F006E00290000003100330030003700300030003700380031002D00330035003100_
    32003400310037003300370038002D003100390030003400330030003000390033002D0031003000_
    300030005F0043006C00610073007300650073005C0057006F00770036003400330032004E006F00_
    640065005C0043004C005300490044005C007B00370037004400320043003900320033002D003700_
    3700370039002D0031003100440038002D0039003000370030002D00300030003000360035004200_
    380034003000000000000000000000000100000005000000540000002C0000002C0000002C000000_
    38000000000000000000000096240000511F0000000000002D0100000C0000000C00000007000000_
    1C010000BC07000054060000D0020000840300007602000038040000460500002A03000046050000_
    AE0600009204000000000000010000004B150000141B0000000000000A0000000A00000002000000_
    020000001C010000C90900000000000001000000C7110000210A0000000000000300000003000000_
    02000000020000001C010000BC0700000100000000000000C7110000ED0300000000000000000000_
    0000000002000000020000001C010000BC0700000000000000000000442D0000511F000000000000_
    000000000D00000005000000050000001C010000B00400007305000083040000C003000078563412_
    040000006A00000001000000010000000B0000000000000001000000020000000300000004000000_
    05000000060000000700000008000000090000000A0000000B000000500072006F00640075006300_
    740069006F006E0000000A00000057006F0072006B004F0072006400650072000000214334120800_
    000088160000F310000078563412070000001401000043007500730074006F006D00650072004100_
    64006400720065007300730020002800530061006C006500730029000000100010060C0000001F00_
    0000020000000300000005000000F4FFFFFF10001006170000001F00000003000000000000000100_
    0000F4FFFFFF100010062B0000005C000000020000000300000005000000F4FFFFFF100010065C00_
    00007D000000020000000300000005000000F4FFFFFF100010060C0000007D000000010000000000_
    000007000000F4FFFFFF100010067D00000086000000020000000300000005000000F4FFFFFF1000_
    10062B00000090000000040000000800000005000000000000000000000001000000050000005400_
    00002C0000002C0000002C0000003400000000000000000000009624000077140000000000002D01_
    0000070000000C000000070000001C010000BC07000054060000D002000084030000760200003804_
    0000460500002A03000046050000AE06000092040000000000000100000088160000F31000000000_
    0000050000000500000002000000020000001C0100007D0A00000000000001000000C7110000320C_
    000000000000040000000400000002000000020000001C010000BC0700000100000000000000C711_
    0000ED03000000000000000000000000000002000000020000001C010000BC070000000000000000_
    00009D3100007614000000000000000000000D00000004000000040000001C010000B00400007305_
    0000C003000078563412040000006C00000001000000010000000B00000000000000010000000200_
    0000030000000400000005000000060000000700000008000000090000000A000000060000005300_
    61006C006500730000001000000043007500730074006F006D006500720041006400640072006500_
    7300730000002143341208000000BD1600009B120000785634120700000014010000530074006F00_
    7200650020002800530061006C006500730029000000547936090000000000000000040000000000_
    00007879360904000000000000000000000000000000000000000000000000000000000000000000_
    000000000000000000000000000000000000FFFFFFFF0B0000000000000002000000010000000300_
    0000000000006F006B00DADADADA000000000D000000610035000000000000000000000000000000_
    000000000000E8793609E87936090000000000000000FFFFFFFF0000000000000000000000000000_
    00000C7A36090C7A360900000000187A3609187A3609000000000000000000000000000000000000_
    00000100000005000000540000002C0000002C0000002C0000003000000000000000000000009624_
    0000A2160000000000002D010000080000000C000000070000001C010000BC07000054060000D002_
    0000840300007602000038040000460500002A03000046050000AE06000092040000000000000100_
    0000BD1600009B12000000000000060000000600000002000000020000001C0100009B0A00000000_
    000001000000C7110000210A000000000000030000000300000002000000020000001C010000BC07_
    00000100000000000000C7110000ED03000000000000000000000000000002000000020000001C01_
    0000BC0700000000000000000000AB170000FB14000000000000000000000D000000030000000300_
    00001C010000B00400007305000078563412040000005800000001000000010000000B0000000000_
    00000100000002000000030000000400000005000000060000000700000008000000090000000A00_
    000006000000530061006C0065007300000006000000530074006F0072006500000003000B00B80B_
    0000EA240000B80B0000D4FEFFFF17080000D4FEFFFF0200000002000000F0F0F000000000000000_
    00000000000000000000010000000800000000000000670C0000570E0000E9110000580100003200_
    0000010000020000E911000058010000020000000000050000800800008001000000150001000000_
    900144420100065461686F6D611C0046004B005F00530074006F00720065005F0043007500730074_
    006F006D00650072005F0043007500730074006F006D0065007200490044002143341208000000AE_
    300000251D00007856341207000000140100005400720061006E00730061006300740069006F006E_
    0048006900730074006F007200790020002800500072006F00640075006300740069006F006E0029_
    0000002D0033003500310032003400310037003300370038002D0031003900300034003300300030_
    00390033002D0031003000300030005F0043006C00610073007300650073005C0057006F00770036_
    003400330032004E006F00640065005C0043004C005300490044005C007B00370037004400320043_
    003900320033002D0037003700370039002D0031003100440038002D0039003000370030002D0030_
    0030003000360035004200380034003000000000000000000000000400000005000000540000002C_
    0000002C0000002C00000030000000000000000000000096240000BB1C0000000000002D0100000B_
    0000000C000000070000001C010000BC07000054060000D002000084030000760200003804000046_
    0500002A03000046050000AE060000920400000000000001000000861C0000E81800000000000009_
    0000000900000002000000020000001C010000E30D00000000000001000000C71100001008000000_
    000000020000000200000002000000020000001C010000BC0700000100000000000000C7110000ED_
    03000000000000000000000000000002000000020000001C010000BC0700000000000000000000AE_
    300000251D000000000000000000000D00000003000000030000001C010000B00400007305000078_
    563412040000007C00000001000000010000000B0000000000000001000000020000000300000004_
    00000005000000060000000700000008000000090000000A0000000B000000500072006F00640075_
    006300740069006F006E000000130000005400720061006E00730061006300740069006F006E0048_
    006900730074006F007200790000002143341208000000161500007F3A0000785634120700000014_
    010000500072006F00640075006300740020002800500072006F00640075006300740069006F006E_
    002900000061006C00750065002000460052004F004D0020007300790073002E0065007800740065_
    006E006400650064005F00700072006F007000650072007400690065007300200057004800450052_
    0045002000280063006C0061007300730020003D00200031002900200041004E004400200028006D_
    0069006E006F0072005F006900640020003D00200030002900200041004E004400200028006D0061_
    006A006F0072005F006900640020003D0020004F0042004A004500430054005F004900440028004E_
    00000000000000000000000100000005000000540000002C0000002C0000002C0000003400000000_
    0000000000000096240000DE200000000000002D0100000D0000000C000000070000001C010000BC_
    07000054060000D0020000840300007602000038040000460500002A03000046050000AE06000092_
    0400000000000001000000161500007F3A000000000000190000000C00000002000000020000001C_
    010000AB0900000000000001000000C7110000771400000000000008000000080000000200000002_
    0000001C010000BC0700000100000000000000C7110000ED03000000000000000000000000000002_
    000000020000001C010000BC0700000000000000000000072C0000DE20000000000000000000000D_
    00000004000000040000001C010000BC07000024090000A005000078563412040000006600000001_
    000000010000000B0000000000000001000000020000000300000004000000050000000600000007_
    00000008000000090000000A0000000B000000500072006F00640075006300740069006F006E0000_
    0008000000500072006F006400750063007400000004000B006E28000092220000B5250000922200_
    00B5250000DE3F000008220000DE3F00000000000002000000F0F0F0000000000000000000000000_
    0000000000010000000C00000000000000EE0D0000982E000018170000580100002F000000010000_
    0200001817000058010000020000000000FFFFFF0008000080010000001500010000009001444201_
    00065461686F6D61270046004B005F005400720061006E00730061006300740069006F006E004800_
    6900730074006F00720079005F00500072006F0064007500630074005F00500072006F0064007500_
    630074004900440002000B00882C0000D0200000882C0000261800000000000002000000F0F0F000_
    00000000000000000000000000000000010000000E00000000000000372D0000CF1B0000ED120000_
    5801000032000000010000020000ED12000058010000020000000000FFFFFF000800008001000000_
    150001000000900144420100065461686F6D611E0046004B005F0057006F0072006B004F00720064_
    00650072005F00500072006F0064007500630074005F00500072006F006400750063007400490044_
    0021433412080000005C1400000E0E00007856341207000000140100004100640064007200650073_
    00730054007900700065002000280050006500720073006F006E002900000061006C007500650020_
    00460052004F004D0020007300790073002E0065007800740065006E006400650064005F00700072_
    006F0070006500720074006900650073002000570048004500520045002000280063006C00610073_
    00730020003D00200031002900200041004E004400200028006D0061006A006F0072005F00690064_
    0020003D0020004F0042004A004500430054005F004900440028004E0027005B00640062006F005D_
    002E005B0052006100740069006E0067005D00270029002900200000000000000000000000010000_
    0005000000540000002C0000002C0000002C000000300000000000000000000000962400004B1200_
    00000000002D010000070000000C000000070000001C010000BC07000054060000D0020000840300_
    007602000038040000460500002A03000046050000AE0600009204000000000000010000005C1400_
    000E0E000000000000040000000400000002000000020000001C0100004209000000000000010000_
    00C7110000210A000000000000030000000300000002000000020000001C010000BC070000010000_
    0000000000C7110000ED03000000000000000000000000000002000000020000001C010000BC0700_
    0000000000000000007D1E00004B12000000000000000000000D00000003000000030000001C0100_
    00B00400007305000078563412040000006600000001000000010000000B00000000000000010000_
    0002000000030000000400000005000000060000000700000008000000090000000A000000070000_
    0050006500720073006F006E0000000C000000410064006400720065007300730054007900700065_
    00000003000B00B605000018150000C012000018150000C0120000050E00000000000002000000F0_
    F0F0000000000000000000000000000000000001000000110000000000000015100000C715000064_
    1C00005801000031000000010000020000641C000058010000020000000000FFFFFF000800008001_
    000000150001000000900144420100065461686F6D612C0046004B005F0043007500730074006F00_
    6D006500720041006400640072006500730073005F00410064006400720065007300730054007900_
    700065005F004100640064007200650073007300540079007000650049004400006E0061006C005F_
    005300700061006E006900730068005F00430053005F00410053005F005700530000005400750072_
    006B006900730068005F00420049004E0000005400750072006B006900730068005F00420049004E_
    00320000005400750072006B006900730068005F00430049005F004100490000005400750072006B_
    006900730068005F00430049005F00410049005F004B00530000005400750072006B006900730068_
    005F00430049005F00410049005F004B0053005F005700530000005400750072006B006900730068_
    005F00430049005F00410049005F005700530000005400750072006B006900730068005F00430049_
    005F004100530000005400750072006B006900730068005F00430049005F00410053005F004B0053_
    000300440064007300530074007200650061006D0000000000000000000000000000000000000000_
    00000000000000000000000000000000000000000000000000160002000300000006000000FFFFFF_
    FF000000000000000000000000000000000000000000000000000000000000000000000000140000_
    00991200000000000053006300680065006D00610020005500440056002000440065006600610075_
    006C0074000000000000000000000000000000000000000000000000000000000026000200FFFFFF_
    FFFFFFFFFFFFFFFFFF00000000000000000000000000000000000000000000000000000000000000_
    00000000001E0000001200000000000000440053005200450046002D0053004300480045004D0041_
    002D0043004F004E00540045004E0054005300000000000000000000000000000000000000000000_
    002C0002010500000007000000FFFFFFFF0000000000000000000000000000000000000000000000_
    000000000000000000000000001F000000B00300000000000053006300680065006D006100200055_
    00440056002000440065006600610075006C007400200050006F0073007400200056003600000000_
    00000000000000000036000200FFFFFFFFFFFFFFFFFFFFFFFF000000000000000000000000000000_
    0000000000000000000000000000000000000000002E00000012000000000000000C00000078ECFF_
    FF05F6FFFF0100260000007300630068005F006C006100620065006C0073005F0076006900730069_
    0062006C0065000000010000000B0000001F00000057EEFFFF64F9FFFFC251000069680000640000_
    00000000000000000000000000000000000000000000000100000001000000000000000000000000_
    00000000000000D00200000600280000004100630074006900760065005400610062006C00650056_
    006900650077004D006F006400650000000100000008000400000034000000200000005400610062_
    006C00650056006900650077004D006F00640065003A00300000000100000008003A00000034002C_
    0030002C003200380034002C0030002C0031003900380030002C0031002C0031003600320030002C_
    0035002C0031003000380030000000200000005400610062006C00650056006900650077004D006F_
    00640065003A00310000000100000008001E00000032002C0030002C003200380034002C0030002C_
    0032003400370035000000200000005400610062006C00650056006900650077004D006F00640065_
    003A00320000000100000008001E00000032002C0030002C003200380034002C0030002C00310039_
    00380030000000200000005400610062006C00650056006900650077004D006F00640065003A0033_
    0000000100000008001E00000032002C0030002C003200380034002C0030002C0031003900380030_
    000000200000005400610062006C00650056006900650077004D006F00640065003A003400000001_
    00000008003E00000034002C0030002C003200380034002C0030002C0031003200300030002C0031_
    0032002C0031003300390035002C00310036002C0033003800340030000000020000000200000000_
    000000000000000000000000000000D0020000060028000000410063007400690076006500540061_
    0062006C00650056006900650077004D006F00640065000000010000000800040000003100000020_
    0000005400610062006C00650056006900650077004D006F00640065003A00300000000100000008_
    003A00000034002C0030002C003200380034002C0030002C0031003900380030002C0031002C0031_
    003600320030002C0035002C0031003000380030000000200000005400610062006C006500560069_
    00650077004D006F00640065003A00310000000100000008001E00000032002C0030002C00320038_
    0034002C0030002C0032003600380035000000200000005400610062006C00650056006900650077_
    004D006F00640065003A00320000000100000008001E00000032002C0030002C003200380034002C_
    0030002C0031003900380030000000200000005400610062006C00650056006900650077004D006F_
    00640065003A00330000000100000008001E00000032002C0030002C003200380034002C0030002C_
    0031003900380030000000200000005400610062006C00650056006900650077004D006F00640065_
    003A00340000000100000008004A00000035002C0030002C003200380034002C0030002C00310032_
    00300030002C00310032002C0031003300390035002C0035002C003900360030002C00310036002C_
    0033003000300030000000030000000300000000000000620000000100170001000000530061006C_
    0065007300000046004B005F0043007500730074006F006D00650072004100640064007200650073_
    0073005F0043007500730074006F006D00650072005F0043007500730074006F006D006500720049_
    00440000000000000000000000C4020000000004000000040000000300000008000000011C3D09C8_
    FC4D090000000000000000AD07000000000005000000050000000000000000000000000000000000_
    0000D00200000600280000004100630074006900760065005400610062006C006500560069006500_
    77004D006F006400650000000100000008000400000031000000200000005400610062006C006500_
    56006900650077004D006F00640065003A00300000000100000008003A00000034002C0030002C00_
    3200380034002C0030002C0031003900380030002C0031002C0031003600320030002C0035002C00_
    31003000380030000000200000005400610062006C00650056006900650077004D006F0064006500_
    3A00310000000100000008001E00000032002C0030002C003200380034002C0030002C0032003500_
    300035000000200000005400610062006C00650056006900650077004D006F00640065003A003200_
    00000100000008001E00000032002C0030002C003200380034002C0030002C003100390038003000_
    0000200000005400610062006C00650056006900650077004D006F00640065003A00330000000100_
    000008001E00000032002C0030002C003200380034002C0030002C00310039003800300000002000_
    00005400610062006C00650056006900650077004D006F00640065003A0034000000010000000800_
    5600000036002C0030002C003200380034002C0030002C0031003200300030002C00310032002C00_
    31003300390035002C0036002C0031003100350035002C0035002C003900360030002C0031003600_
    2C003900390030000000060000000600000000000000000000000000000000000000D00200000600_
    280000004100630074006900760065005400610062006C00650056006900650077004D006F006400_
    650000000100000008000400000031000000200000005400610062006C0065005600690065007700_
    4D006F00640065003A00300000000100000008003A00000034002C0030002C003200380034002C00_
    30002C0031003900380030002C0031002C0031003600320030002C0035002C003100300038003000_
    0000200000005400610062006C00650056006900650077004D006F00640065003A00310000000100_ 
    000008001E00000032002C0030002C003200380034002C0030002C00320037003100350000002000_ 
    00005400610062006C00650056006900650077004D006F00640065003A0032000000010000000800_ 
    1E00000032002C0030002C003200380034002C0030002C0031003900380030000000200000005400_ 
    610062006C00650056006900650077004D006F00640065003A00330000000100000008001E000000_ 
    32002C0030002C003200380034002C0030002C003100390038003000000020000000540061006200_ 
    6C00650056006900650077004D006F00640065003A00340000000100000008002E00000033002C00_ 
    30002C003200380034002C0030002C0031003200300030002C00310032002C003100330039003500_ 
    00000700000007000000000000004E00000001FF4D5501000000530061006C006500730000004600_ 
    4B005F00530074006F00720065005F0043007500730074006F006D00650072005F00430075007300_ 
    74006F006D00650072004900440000000000000000000000C4020000000008000000080000000700_ 
    000008000000011C3D0948FE4D090000000000000000AD0700000000000900000009000000000000_ 
    00000000000000000000000000D00200000600280000004100630074006900760065005400610062_ 
    006C00650056006900650077004D006F006400650000000100000008000400000034000000200000_ 
    005400610062006C00650056006900650077004D006F00640065003A00300000000100000008003A_ 
    00000034002C0030002C003200380034002C0030002C0031003900380030002C0031002C00310036_ 
    00320030002C0035002C0031003000380030000000200000005400610062006C0065005600690065_ 
    0077004D006F00640065003A00310000000100000008001E00000032002C0030002C003200380034_ 
    002C0030002C0033003500350035000000200000005400610062006C00650056006900650077004D_ 
    006F00640065003A00320000000100000008001E00000032002C0030002C003200380034002C0030_ 
    002C0031003900380030000000200000005400610062006C00650056006900650077004D006F0064_ 
    0065003A00330000000100000008001E00000032002C0030002C003200380034002C0030002C0031_ 
    003900380030000000200000005400610062006C00650056006900650077004D006F00640065003A_ 
    00340000000100000008003E00000034002C0030002C003200380034002C0030002C003100320030_ 
    0030002C00310032002C0031003300390035002C00310036002C00330038003400300000000A0000_ 
    000A00000000000000000000000000000000000000D0020000060028000000410063007400690076_ 
    0065005400610062006C00650056006900650077004D006F00640065000000010000000800040000_ 
    0031000000200000005400610062006C00650056006900650077004D006F00640065003A00300000_ 
    000100000008003A00000034002C0030002C003200380034002C0030002C0031003900380030002C_ 
    0031002C0031003600320030002C0035002C0031003000380030000000200000005400610062006C_ 
    00650056006900650077004D006F00640065003A00310000000100000008001E00000032002C0030_ 
    002C003200380034002C0030002C0032003400370035000000200000005400610062006C00650056_ 
    006900650077004D006F00640065003A00320000000100000008001E00000032002C0030002C0032_ 
    00380034002C0030002C0031003900380030000000200000005400610062006C0065005600690065_ 
    0077004D006F00640065003A00330000000100000008001E00000032002C0030002C003200380034_ 
    002C0030002C0031003900380030000000200000005400610062006C00650056006900650077004D_ 
    006F00640065003A00340000000100000008003E00000034002C0030002C003200380034002C0030_ 
    002C0031003900380030002C00310032002C0032003300340030002C00310031002C003100340034_ 
    00300000000B0000000B000000000000006E00000001004D5501000000500072006F006400750063_ 
    00740069006F006E00000046004B005F005400720061006E00730061006300740069006F006E0048_ 
    006900730074006F00720079005F00500072006F0064007500630074005F00500072006F00640075_ 
    00630074004900440000000000000000000000C402000000000C0000000C0000000B000000080000_ 
    00011C3D0908FD4D090000000000000000AD0700000000000D0000000D000000000000005C000000_ 
    0100000001000000500072006F00640075006300740069006F006E00000046004B005F0057006F00_ 
    72006B004F0072006400650072005F00500072006F0064007500630074005F00500072006F006400_ 
    7500630074004900440000000000000000000000C402000000000E0000000E0000000D0000000800_ 
    0000011C3D0908024E090000000000000000AD0700000000000F0000000F00000000000000000000_ 
    000000000000000000D00200000600280000004100630074006900760065005400610062006C0065_ 
    0056006900650077004D006F00640065000000010000000800040000003100000020000000540061_ 
    0062006C00650056006900650077004D006F00640065003A00300000000100000008003A00000034_ 
    002C0030002C003200380034002C0030002C0031003900380030002C0031002C0031003600320030_ 
    002C0035002C0031003000380030000000200000005400610062006C00650056006900650077004D_ 
    006F00640065003A00310000000100000008001E00000032002C0030002C003200380034002C0030_ 
    002C0032003300370030000000200000005400610062006C00650056006900650077004D006F0064_ 
    0065003A00320000000100000008001E00000032002C0030002C003200380034002C0030002C0031_ 
    003900380030000000200000005400610062006C00650056006900650077004D006F00640065003A_ 
    00330000000100000008001E00000032002C0030002C003200380034002C0030002C003100390038_ 
    0030000000200000005400610062006C00650056006900650077004D006F00640065003A00340000_ 
    000100000008003C00000034002C0030002C003200380034002C0030002C0031003200300030002C_ 
    00310032002C0031003300390035002C00310036002C003900390030000000100000001000000000_ 
    0000006E0000000100000001000000530061006C0065007300000046004B005F0043007500730074_ 
    006F006D006500720041006400640072006500730073005F00410064006400720065007300730054_ 
    007900700065005F0041006400640072006500730073005400790070006500490044000000000000_ 
    0000000000C4020000000011000000110000001000000008000000011C3D09C8004E090000000000_ 
    000000AD070000000000190000000700000001000000060000005800000051000000030000000100_ 
    000002000000820000001D0000000D0000000A000000050000000C0000000D0000000B0000000A00_ 
    0000090000004A000000A9000000100000000F00000002000000490000000B0000000072006F006B_ 
    0065005F00390030005F00420049004E00320000004300680069006E006500730065005F00540061_ 
    006900770061006E005F005300740072006F006B0065005F00390030005F00430049005F00410049_ 
    0000004300680069006E006500730065005F00540061006900770061006E005F005300740072006F_ 
    006B0065005F00390030005F00430049005F00410049005F004B00530000004300680069006E0065_ 
    00730065005F00540061006900770061006E005F005300740072006F006B0065005F00390030005F_ 
    00430049005F00410049005F004B0053005F005700530000004300680069006E006500730065005F_ 
    00540061006900770061006E005F005300740072006F006B0065005F00390030005F00430049005F_ 
    00410049005F005700530000004300680069006E006500730065005F00540061006900770061006E_ 
    005F005300740072006F006B0065005F00390030005F00430049005F0041005300200053006F0075_ 
    007200630065003D00480045004C004C004F003B0049006E0069007400690061006C002000430061_ 
    00740061006C006F0067003D0041006400760065006E00740075007200650057006F0072006B0073_ 
    003B005000650072007300690073007400200053006500630075007200690074007900200049006E_ 
    066006F003D0054007200750065003B0055007300650072002000490044003D00730061003B004D0_ 
    075006C007400690070006C00650041006300740069007600650052006500730075006C007400530_ 
    06500740073003D00460061006C00730065003B005000610063006B00650074002000530069007A0_ 
    065003D0034003000390036003B004100700070006C00690063006100740069006F006E0020004E0_ 
    061006D0065003D0022004D006900630072006F0073006F00660074002000530051004C002000530_ 
    06500720076006500720020004D0061006E006100670065006D0065006E007400200053007400750_ 
    0640069006F0022000000008005001E0000004500780061006D0070006C006500440069006100670_ 
    0720061006D000000000226001800000041006400640072006500730073005400790070006500000_ 
    00E00000050006500720073006F006E0000000002260010000000500072006F00640075006300740_ 
    0000016000000500072006F00640075006300740069006F006E00000000022600260000005400720_ 
    061006E00730061006300740069006F006E0048006900730074006F0072007900000016000000500_ 
    072006F00640075006300740069006F006E000000000226000C000000530074006F0072006500000_ 
    00C000000530061006C00650073000000000226001400000057006F0072006B004F0072006400650_ 
    07200000016000000500072006F00640075006300740069006F006E0000000002260020000000430_ 
    07500730074006F006D0065007200410064006400720065007300730000000C000000530061006C0_ 
    0650073000000000224001200000043007500730074006F006D006500720000000C0000005300610_ 
    06C0065007300000001000000D68509B3BB6BF2459AB8371664F0327008004E0000007B003900310_ 
    03500310030003600300038002D0038003800300039002D0034003000320030002D0038003800390_ 
    037002D004600420041003000350037004500320032004400350034007D000000000000000000000_ 
    00000000000000000010003000000000000000C00000010000000000000000000000000000000000_ 
    00000000000000000000000000000000000000000000000000000000000000000000000000000000_ 
    00000000000000000000000000000000000000000000000000000000000000000000000000000000_ 
    00000000000000000000000000000000062885214
)

-- Show all available diagrams
SELECT * FROM [dbo].[sysdiagrams] ORDER BY [name] ASC

That's it. Now you can save the new script and use it to recreate your diagrams.

Points of Interest

This is just a "manual" way of doing it, you can iterate through all diagrams and generate a script that saves all of them at once (go ahead - make my day).

History

  • 16th October, 2009: Initial post

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)