Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. How to copy sysDiagrams when copying a database

How to copy sysDiagrams when copying a database

Scheduled Pinned Locked Moved C#
helpdatabaseannouncementsql-serversysadmin
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • F Offline
    F Offline
    fiaolle
    wrote on last edited by
    #1

    Hi I have the code below wich copies a database to the same server with a different name, 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(); 
    

    Fia

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups