What is the problem with this command.
SELECT *  INTO database2.table2 FROM database1.table1;
It returns this error:
ERROR 1327 (42000): Undeclared variable: database2
The goal is to transfer data in table1 to database2.
What is the problem with this command.
SELECT *  INTO database2.table2 FROM database1.table1;
It returns this error:
ERROR 1327 (42000): Undeclared variable: database2
The goal is to transfer data in table1 to database2.
 
    
    select ... into is for storing values in variables. See the documenation for more details.
What you need is an insert into .. select ..
insert into database2.table2 (select * from database1.table1)
 
    
    Use:
CREATE TABLE database2.table2 AS select * from database1.table1;
MySQL probably does not support SELECT ... INTO ... FROM syntax.
 
    
    You should use something like that :
INSERT INTO newDatabase.table1 (Column1, Column2)
SELECT column1, column2 FROM oldDatabase.table1;
 
    
    Use this query :
 insert into database2.table2 
  select * from database1.table1;
 
    
    If those two databases are not connected to each other, you should think about that first.
Connect two databases
Use Linked Server for SQL Server. 
To know about how to create a linked server, See this link.
Then use the query:
insert into database2.table2 
    select * from database1.table1;
The syntax is:
INSERT INTO ToTableName 
    SELECT */ColNames FROM FromTableName
 
    
    