How to copy sysdiagrams to another database

F

fiaolle

Hi
I have the code below wich copies a database, but the Database Diagram isn't
copied. I need it because of the relationship between tables, primary keys,
foreign keys, delete rules and update rules as cascade. I have googled but
haven't found anything that works. I found this code, 'insert into
B.dbo.sysdiagrams select [name], principal_id, version,definition from
A.dbo.sysdiagrams', but the sysdiagrams isn't copied to the database when
I'm running the code below. And before when I ran the code below I didn't
get any errors, but now I get the error errorCode=-1073548784. Although the
error the database is created but without the Database Diagram, the
sysdiagram. If anybody have a solution to this problem, please help me. I'm
using SQL Server 2008.

Transfer transfer = new Transfer(server.Databases["Questions"]);
transfer.CopyAllObjects = true;
transfer.CopyAllUsers = true;
transfer.CopyAllTables = true;
transfer.Options.WithDependencies = true;
transfer.Options.NoIdentities = false;
transfer.DestinationDatabase = newdb.Name;
transfer.DestinationServer = server.Name;
transfer.DestinationLoginSecure = true;
transfer.CopySchema = true;
transfer.CopyData = true;
transfer.Options.DriAllKeys = true;
transfer.CopyAllStoredProcedures = true;
transfer.Options.ContinueScriptingOnError = true;
transfer.TransferData();
 
I

Ignacio Machin ( .NET/ C# MVP )

Hi
I have the code below wich copies a database, but the Database Diagram isn't
copied. I need it because of the relationship between tables, primary keys,
foreign keys, delete rules and update rules as cascade. I have googled but
haven't found anything that works. I found this code, 'insert into
B.dbo.sysdiagrams select [name], principal_id, version,definition from
A.dbo.sysdiagrams', but the sysdiagrams isn't copied to the database when
I'm running the code below. And before when I ran the code below I didn't
get any errors, but now I get the error errorCode=-1073548784.  Although the
error the database is created but without the Database Diagram, the
sysdiagram. If anybody have a solution to this problem, please help me. I'm
using SQL Server 2008.

This question should be posted in a SQL NG, it has nothing to do with
C#
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top