I have two identical databases on the same server. During a deployment process, I have data in tables in database A that need copied over to the tables in database B. What is the easiest way to programmatically accomplish this task?
EDIT:
- Tables do have identity columns.
- There are tables with foreign key constraints, so insert order is important.
- All of the rows will need to be copied. As far as I’m aware, this will always be the case.
Assuming that the tables don’t have identity columns and belongs to the default (dbo) schema, try the TSQL insert query below;
If you have an identity column then execute statements below