Copy tables from one database to another in SQL Server
I have a database called FirstDatabase and a database called SecondDatabase. I have a 40 table's in FirstDatabase that I want to COPY (data and all) from FirstDatabase to SecondDatabase. What is the SQL statement to do this?


Manoj BhoirRank #599 · 4K reputationPosted Jun 17, 2015, 11:48 PM EDT
SQL Server Management Studio's "Import Data" task (Right-Click on the DB name, then Tasks) will do most of this for you. Run it from the database you want to copy the data into.
If the tables don't exist it will create them for you, but you'll probably have to recreate any indexes and such. If the tables do exist, it will append the new data by default but you can adjust that (edit mappings) so it will delete all existing data.
Govinda Rajulu YemineniRank #1,517 · 1K reputationPosted Jul 16, 2015, 4:26 AM EDT
Rajeesh MenothRank #118 · 18.4K reputationPosted Jul 16, 2015, 7:18 AM EDT
Raja TRank #685 · 3.5K reputationPosted Jul 16, 2015, 9:15 AM EDT
Please checkout below URL....
http://blog.sqlauthority.com/2009/07/29/sql-server-2008-copy-database-with-data-generate-t-sql-for-inserting-data-from-one-table-to-another-table/