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?
2 Answers
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".
Comments
Using SQL replication or data compare with other tools. ex: Redgate SQL Data Compare.
2 Comments
Dale K
Answers need to provide a complete solution to the question asked, not just tips and resources.
Community
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.
INSERT INTO .... SELECTqueries (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.