Introduction
Hello. Some of you might have already encountered this, while others will encounter it in SQL interviews. Here are the solutions for the questions an interviewer might ask you. That is, how to copy or migrate one table's content to another within a database or across databases.
Copy Table Data within the Database
Let us take a database. Here iShrissDB is my database with a table UserDetails that is to copy.
select * into newTable Name from oldTable Name
For example

use iShrissdb
select * into dbo.Details from dbo.UserDetails

Then
Copy Table Data across two Databases
select * into [new Database].newTable from [old database].oldTable
Let us take the two databases, iShrissDB and DBEngine. As we can see, we have a table named UserDetails in the iShrissDB database; we will copy this table from the iShrissDB database to the DBEngine database.

use iShrissdb
select * into [DBEngine].dbo.newTable from [iShrissdb].dbo.UserDetails

Copying Table with the same Table name
select * into [DBEngine].[dbo].UserDetails from [iShrissdb].[dbo].UserDetails

Summary
We learned how to navigate a table within SQL Server databases.

Dinesh GabhanePosted Nov 11, 2019, 1:31 AM
Good One...
Shridhar SharmaPosted Mar 22, 2015, 4:50 AM
thanks Gowtham Rajamanickam sir :)
Gowtham RajamanickamPosted Mar 21, 2015, 11:55 AM
nice one..
Shridhar SharmaPosted Mar 20, 2015, 10:38 AM
thank you .
Saineshwar BageriPosted Mar 20, 2015, 2:03 AM
nice one