Copy tables and data from one database to another in SQL Server 2005
Hello,
I have 2 databases. One for production and the other is a live database. I want to schedule a job that copies only the tables and data from the live db to the development db in order to replace the dev data with real data. There are many tables and I need the correct identities in the dev db that will come over from the live db. I will also need to have some sort of control over which tables to copy.
What is the best way to do this as a scheduled job?
Thanks!
Microsoft SQL Server 2005Microsoft SQL Server
Last Comment
yuching
8/22/2022 - Mon
puranik_p
If both the databases are on the same server, you can simply drop and recreate the tables...
DROP TABLE devdb.dbo.table1SELECT * INTO devdb.dbo.table1 FROM livedb.dbo.table1DROP TABLE devdb.dbo.table2SELECT * INTO devdb.dbo.table2 FROM livedb.dbo.table2-- and so on
Do you want to copy the data for all tables from live db to development db?
yuching
Just a suggestion, you can create a DTS package (put the sql task to be completed in the DTS package) and schedule the DTS to run on once every day/week
RE DTS:
I had to create several packages since there a too many tables to copy over to the dev db all at once. How can I run them one after the other - in a certain order?
Thanks!
yuching
you can create each different Transform Data Task/ Execute SQL task and execute then in order.
You can refer below link for DTS
Open in new window