I am trying to use OUTPUT clause to select a column but failed. Here is a quick example,
create table A (id int, name varchar(10))
create table B (id int)
insert into A values(1,'a'),(2,'b'),(3,'c')
declare @Inserted TABLE (ID INT, name varchar(10));
INSERT INTO B
OUTPUT INSERTED.ID, a.name INTO @Inserted
select id from a
I am getting this error,
The multi-part identifier "a.name" could not be bound.