*

Sep 29 2011

When merging, watch your asterisk

Recently, while working with T-SQL's merge statement and its output clause I ran across an error I couldn't track down.  My statement looked something like this:

 

Merge #target_1 as target using 
(select value1 from #source ) as source 
on target.value1 = source.value1 
when not matched then insert (value1) values (value1) 
OUTPUT $action, inserted.* into #action_target;

The code was producing this error

Msg 213, Level 16, State 1, Line 25
Column name or number of supplied values does not match table definition.

Read More