-1

I have created a database in SQL Server named "devdatabase" and another named "pocdatabase". Both of these databases have the same tables but only devdatabase has data populated in the tables. What is the best way to populate pocdatabase with the same data in the devdatabase tables?

1
  • 1
    Best way to move databases is to back up a database and restore it on another server. If you specifically want to copy, then there are a few choices: 1. As per @Teodor Nitica, you can write INSERT INTO .... SELECT queries (Excel can help with generating these queries) 2. Use a data compare tool such as "Redgate SQL Data Compare". There are lots of tools available, some free, some not so free. Commented Jun 15, 2022 at 3:23

2 Answers 2

1

It depends on how many tables there are and only if you want the data in the tables or to copy other objects. If there are not hundreds of tables I would use append queries.

INSERT INTO DestinationDB.dbo.tableName SELECT * FROM SourceDB.dbo.SourceTable
INSERT INTO pocdatabase.dbo.tableName SELECT * FROM devdatabase.dbo.tableName

DestinationDB="pocdatabase" SourceDB="devdatabase" I assumed that the table names are identical. If you have a lot of tables so the above method is tedious then you could backup the "devdatabase" then restore the backup in "pocdatabase".

Sign up to request clarification or add additional context in comments.

Comments

-1

Using SQL replication or data compare with other tools. ex: Redgate SQL Data Compare.

2 Comments

Answers need to provide a complete solution to the question asked, not just tips and resources.
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.