-1

I have two tables, 2012 and 2018, each in different databases. I am currently using SQL Server.

The 2012 table has data filled in, while the 2018 table has the same exact columns, but is empty. I want to copy data from the 2012 table to the 2018 table. I tried looking it up online, but most of the information pertained to other versions of SQL (MySQL, Oracle, etc.)

I would very much appreciate some help with this. Thank you.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Kyodi
  • 31
  • 8
  • Exactly how you would do it for any other table, just fully-qualify the name of the target/source eg database.schema.table – Stu Jun 24 '21 at 15:40

1 Answers1

0

Assuming your databases are on the same server and you are connecting as sa or user with full read/write permissions and using the default dbo schema,

use <Database with table [2012]>
go
insert into <databaseWith[2018]>.dbo.[2018](col, col, col...)
select col, col, col...
from [2012]
Stu
  • 30,392
  • 6
  • 14
  • 33