T-SQL INSERT INTO with LEFT JOIN
INSERT INTO [DB_A].[dbo.a_test] (a,b,c, d)
SELECT dbo.products.product_info, dbo.products.product_date, dbo.products.smth, dbo.program.program_smth
FROM [DB_B].dbo.products
LEFT JOIN [DB_B].dbo.program
ON dbo.program.program_name = dbo.products.product_info
You want insert into . . . select
:
INSERT INTO [DB_A].[dbo.a_test](a,b,c,d,e) --ADDED A COLUMN
select p.product_info, p.product_date, p.smth, pr.program_name, pr.program_smth
FROM [DB_B].dbo.products p LEFT JOIN
[DB_B].dbo.program pr
ON p.program_name = pr.product_info;
I also fixed the query to use table aliases, so it is much easier to read.