Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6062677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T09:04:46+00:00 2026-05-23T09:04:46+00:00

I need to create a tool that is able to merge clients production databases.

  • 0

I need to create a tool that is able to merge clients production databases.
Usually these databases will have the same schema (I’ll do some check’s later on, but for now we’ll assume it is). Filtering of duplicate data is something for later on too.
This needs to be done automaticly(so no script generation via SSMS etc).
I’ve already had to start over again a couple of times because every time I ran into problems for things I didn’t think off, so this time I wanted to ask you guys for advice before I begin all over again.

My current plan of action is:

  • Copy schema from database 1(later on I’ll add some checks here for
    when the schema is different
  • Loop over all tables and set all foreign key updates to cascade, and
    set the order in which the tabledata needs to be inserted (so the
    tables containing the PK’s first, then the tables holding the FK’s)
  • Loop every table in the correct order

    • Check in database 2 table for identity column, if so, retrieve the
      current seed value from the corresponding table in database 1, drop
      identity property on database 2 table and update each ID to newID =
      currentID + seed(to avoid duplicate primary keys later on)
    • Generate insert script(SMO’s Table.EnumScript) for database 1 table
    • Generate insert script(SMO’s Table.EnumScript) for database 2 table
    • Execute every line in database 1 insert script on the new database
    • Execute every line in database 2 insert script(which now has primary
      keys/identity field data that will follow the ones in database 1) on the new database
  • Go to next table

Everything was working when testing(disabling the identity property in SSMS, created a T-SQL script to update every row with the given seed,..)
But the problem now is automating this in C#, more specific the disabling of the identity property. There doesn’t seem to be a clean solution for this. Creating a new table and rebuilding every constraint etc seems like the wrong way, because the only reason I need it is to cascade every FK so everything still points to the correct place..

Another way would be to delay the updating of the identity-column-data, and change it after script generation and before insertion in the new database. But then I’d need to know which data points to which other data, while everything is still in strings(insertscript)?

Any suggestions,thoughts or techniques on how to handle this?

I know about Red Gate ‘s SQL compare, and it is indeed wonderfull, but need to program it myself.

Using: SMO, SQL Server 2005 – 2008R2(no developers or enterprise edition on client servers), ADO.NET , C#, .NET framework 2.0, Visual Studio 2008

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T09:04:46+00:00Added an answer on May 23, 2026 at 9:04 am

    I am not sure exactly what you are trying to accomplish with your process here, but managing Database versions is something that I have a keen interest in.
    Have a look at DBSourceTools ( http://dbsourcetools.codeplex.com ).
    It is a utility to script an entire database to disk, including all foreign key constraints and data.
    Using Deployment Targets, you will then be able to re-create these databases on another database server (usually local machine).
    The tool will handle dependencies and large database tables using Sql Bulk insert – trying to generate a script with 50,000 insert statements will be a nightmare.
    Have fun.

    Disclaimer: I am involved in the http://dbsourcetools.codeplex.com project.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to create a tool that will check a domains live mx records
I need to create an XML schema that looks something like this: <xs:element name=wrapperElement>
I need to create a button that has the same style as ButtonSpec with
I need to create a backup of a SQL Server 2005 Database that's only
My PHP application will need to be able to export to (and import from)
I need to create a Web-based Dashboard tool for a LOB application. Essentially users
Hello All I am writing some software that will allow users to create their
I have a shiny WPF (4.0) app that I need to add Crystal Reports
I need to create a historical timeline starting from 1600's to the present day.
I need to create a linked server to a DB2 database on a mainframe.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.