none
Combine two SQL database into one RRS feed

  • Question

  • I Have two database with the same table and schema but different data in 2 Computer  , 1st one old SQL version and the 2nd one is new . 

    Now i just want  to Create a new database Combine with 2 Existing Database.


    • Edited by Udoy Monday, September 16, 2019 6:44 PM
    Monday, September 16, 2019 6:43 PM

All replies

  • If you don't want to do this manually, I believe you will need a tool (Database Merger).

    Ex: http://sql-hub.com/Page/index.php?Shortname=Home

    Monday, September 16, 2019 6:56 PM
  • Hi Udoy

    Please try to use the SQL server import and Export Wizard follow below steps:

    •  Right click on the database you want to copy
    •  'Tasks' > 'Export Data'
    •  Next, Next
    •  Choose the database to copy the tables to
    •  Mark 'Copy data from one or more tables or views'
    •  Choose the tables you want to copy
    •  Finish

    Or you can try to use Generate and Publish Scripts follow below steps:
      Right click on the database you want to copy
    • Choose 'Tasks' > 'Generate scripts'
    • 'Select specific database objects'
    • Check 'Tables'
    • Mark 'Save to new query window'
    • Click 'Advanced'
    • Set 'Types of data to script' to 'Schema and data'
    • Next, Next
    You can now run the generated query on the new database. 

    Please refer to Transfer data from one database to another database.

    Best regards,
    Cathy 


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com




    Tuesday, September 17, 2019 3:08 AM
  • I Have two database with the same table and schema but different data in 2 Computer  , 1st one old SQL version and the 2nd one is new . 

    Now i just want  to Create a new database Combine with 2 Existing Database.


    If all databases are supposed to be in the same server

    you can simply do this

    USE NewDB
    GO
    
    INSERT INTO TableName
    SELECT Columns... FROM DB1.Schema.TableName
    UNION ALL
    SELECT Columns... FROM DB2.Schema.TableName

    Things to note

    1. if there are rows with same key coming from both databases you've to determine how to handle them i.e whether to preserve the key in new db or generate a new one (like sequential or identity) or merge the data from both dbs into single row (in which case logic for merge also have to be determined)

    2.  If you want to insert identity values as is from source to your destination db table, you should set IDENTITY_INSERT option to ON



    Please Mark This As Answer if it solved your issue
    Please Vote This As Helpful if it helps to solve your issue
    Visakh
    ----------------------------
    My Wiki User Page
    My MSDN Page
    My Personal Blog
    My Facebook Page

    Tuesday, September 17, 2019 6:02 AM
    Moderator
  • Hi Udoy,

    Did you resolve your issue?If you have resolved your issue, please mark the useful reply as answer. This can be beneficial to other community members reading the thread.
    In addition, if you have another questions, please feel free to ask.
    Thanks for your contribution.

    Best regards,
    Cathy 

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to  MSDN Support, feel free to contact MSDNFSF@microsoft.com

    Friday, September 20, 2019 9:53 AM