Is there a way to copy a SQL Server Database Diagram to another server?
I found this and modified it sightly to copy only one diagram:
INSERT INTO dbB.dbo.sysdiagrams
SELECT [name],[principal_id],[version],[definition]
FROM dbA.dbo.sysdiagrams
Where name = 'MyDiagramName'
But I need to copy it to another Server (Development to Production).
I don't want to create a linked server to do this. (Updated explanation) The reason behind that is that I want to include the diagram in a upgrade script. I made changes to the database to support a new version (new tables, etc) and I want the diagram be be part of the upgrade script. so it's best if i could put that in a SQL script. If a got a separated file to manually import afterward, it could do the job, but it not the best.
So i need to 'save' the diagram definition to a file somehow to restore it on the other server.
Right click on the database containing the diagrams. Click on All Tasks then on "Export data". The Import / Export option will be displayed, click Next. Define the source and then click Next.
Just found this solution.
In this article, There's the code to create the Stored Procedure that generate a SQL Server Script to recreate the diagrams. So you just save the output of the Stored Procedure in a .SQL file and run it on the other server.
The problem is to convert Varbinary To a String (Varchar) in Hex in order to be able use it in a insert/update query. But it's well explained in the link...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With