I am trying to delete all records from a table in one database, and repopulate it with a select statement retrieving data from another database.
This is what I have so far...
DELETE * FROM Database2.Table3;
INSERT INTO Database2.Table3
SELECT * from Table1
join Database2.Table2
on ColumnX = ColumnY
But I get the following error...
Msg 213, Level 16, State 1, Line 2
Column name or number of supplied values does not match table definition.
What I am wanting is the Data Records in Database1, Table1, and I am matching a column from it to Database2, Table2, and then inserting that matched data into Database2, Table 3.
But with the INSERT Statement, I am thinking I need Values as well, but I want ALL records that match, and there are like 25+ columns, so it would be a very lengthy Values().
What am I missing here?
This is what I have so far...
DELETE * FROM Database2.Table3;
INSERT INTO Database2.Table3
SELECT * from Table1
join Database2.Table2
on ColumnX = ColumnY
But I get the following error...
Msg 213, Level 16, State 1, Line 2
Column name or number of supplied values does not match table definition.
What I am wanting is the Data Records in Database1, Table1, and I am matching a column from it to Database2, Table2, and then inserting that matched data into Database2, Table 3.
But with the INSERT Statement, I am thinking I need Values as well, but I want ALL records that match, and there are like 25+ columns, so it would be a very lengthy Values().
What am I missing here?