I have two tables Table1
, Table2
. From Table1
want to transfer data to Table2
.
Suppose I have the following query:
Select *
from Table1
where UserID between 5 and 10
I want to store above result to Table2
. Both tables save same type of columns. How to transfer data from table to table?
If have any questions, please ask.
Best Answer
following INSERT INTO statement:
Now suppose you do not want to copy all the rows, but only those rows that meet a specific criteria. Say you only want to copy those rows where COL1 is equal to "A." To do this you would just modify the above code to look like this:
See how simple it is to copy data from one table to another using the INSERT INTO method? You can even copy a selected set of columns, if you desire, by identifying the specific columns you wish to copy and populate, like so:
The above command copies only data from columns COL1, COL4, and COL7 in TABLE1 to COL1, COL2, and COL3 in TABLE2.