Hi,
I have a stored procedure with conditional logic that returns data for an SSIS datasource. The various conditions in the sproc return the same column names and datatypes, but they still fail the "sp_describe_first_result_set" call from SSIS. After some digging around, I discovered that one of the conditions returns a "hidden" column that is used for lookup purposes, and this is not contained in the other conditions. How can I resolve this so that SSIS doesn't complain about metadata not matching up?
The conditional query in the sproc is below:
if @RunTypeLoc <> 'REL' and @RowVersionMinLoc = 0 begin SELECT pk_col, xxx, yyy, zzz, CAST('' AS NCHAR(1)) AS sys_change_operation FROM [dbo].aaa; end else IF @RunTypeLoc = 'INC' begin SELECT ct.pk_col, xxx, yyy, zzz, ct.sys_change_operation FROM [dbo].xxx x RIGHT OUTER JOIN CHANGETABLE(CHANGES dbo.xxx, @RowVersionMinLoc) AS ct ON x.pk_col= ct.pk_col WHERE ct.sys_change_version <= @RowVersionMaxLoc; END else if @RunTypeLoc = 'REL' begin SELECT pk_col, xxx, yyy, zzz, CAST('' AS NCHAR(1)) AS sys_change_operation FROM [dbo].xxx where yyy in (select yyy from aaa); endThe middle condition, which uses the CHANGETABLE function, returns dbo.xxx.pk_col as a hidden column.