From be4ec5aebf88bc806785887f6111b43ec42f694d Mon Sep 17 00:00:00 2001 From: Will Beasley Date: Wed, 21 Jun 2017 16:16:47 -0500 Subject: [PATCH] migrate diagrams to new database They're not defined in the 'generate-db.sql' file. See #15. --- .../database/diagrams/migrate-diagrams.sql | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 data-public/metadata/database/diagrams/migrate-diagrams.sql diff --git a/data-public/metadata/database/diagrams/migrate-diagrams.sql b/data-public/metadata/database/diagrams/migrate-diagrams.sql new file mode 100644 index 0000000..07e7014 --- /dev/null +++ b/data-public/metadata/database/diagrams/migrate-diagrams.sql @@ -0,0 +1,38 @@ +--Requires a "Linked server": https://docs.microsoft.com/en-us/sql/relational-databases/linked-servers/linked-servers-database-engine +--Code from https://stackoverflow.com/questions/527327/how-do-you-migrate-sql-server-database-diagrams-to-another-database + +SELECT [name] + ,[principal_id] + ,[diagram_id] + ,[version] + ,[definition] + FROM [BEE\BASS].[NlsLinks].[dbo].[sysdiagrams] + + + + +USE NlsLinks + +DELETE sysDiagrams +WHERE name IN ( + SELECT name FROM [BEE\BASS].[NlsLinks].[dbo].[sysdiagrams] + ) + +SET IDENTITY_INSERT sysDiagrams ON + +INSERT sysDiagrams ( + name, + principal_id, + diagram_id, + version, + definition +) +SELECT + name, + principal_id, + diagram_id, + version, + definition +FROM [BEE\BASS].[NlsLinks].[dbo].[sysdiagrams] + +SET IDENTITY_INSERT sysDiagrams OFF