I am trying to Copy Data from One Table to the Other Database Table But the query is not working

--NOT WORKING
SELECT * INTO CustomersTOnextDB IN 'BackupDB'
FROM Customers;

http://www.w3schools.com/sql/sql_insert_into_select.asp

SELECT *
INTO BackupDB..CustomersTOnextDB
FROM Customers;
1 Like

or ... if the CustomersTOnextDB table already exists, in the BackupDB database, then

INSERT INTO BackupDB..CustomersTOnextDB
SELECT *
FROM Customers;

This assumes that the columns in BackupDB..CustomersTOnextDB table are in the same sequence as the column in the Customers table in the connected-database. This is a somewhat risky proposition as that may change in the future. SELECT * is always risky in that regard, so you might prefer to do

INSERT INTO BackupDB..CustomersTOnextDB
(
    Col1, Col2, ...
)
SELECT Col1, Col2, ...
FROM Customers;
2 Likes