views:

53

answers:

2

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.

A: 

This tutorial/example will explain it

http://www.sharpdeveloper.net/content/archive/2008/04/19/copy-a-database-diagram-to-another-database.aspx

greektreat
This use a 'temporary table'. that don't work for the another Server scenario.
DavRob60
Have you ever used a link server?
greektreat
Yes, but I want to do it without, that's part of the question.
DavRob60
A: 

Just found this solution.

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...

DavRob60