Home Forums SQL Server 2012 SQL Server 2012 - T-SQL SQL 2012 ERROR - The metadata could not be determined because statement contains dynamic SQL RE: SQL 2012 ERROR - The metadata could not be determined because statement contains dynamic SQL

  • Thanks for the feedback. Using WITH RESULT SETS seems to have gotten me past error. I'm not super excited about the prospect of combing through current stored procedures, determining which are touched by SSIS, and altering them accordingly. Actually, it won't be me most likely so I guess it's not that bad.

    Just for reference with respect to the topic, I had mentioned that a proc called from SSIS that includes the execution of dynamic sql was the issue in this case. I had never seen or used "WITH RESULT SETS" syntax and was a little unclear as to how to implement it in my case. Here's a before and after example based loosely on the original block of problem code, and what I changed it to:

    Blows up:

    EXEC sp_executesql @Sql, @Parms,

    @IdParam = @Id,

    @IdParam2 = @TransactionId,

    @OriginalDataValueOut = @FieldDataValue OUTPUT,

    @ResultOut = @ResultFrom OUTPUT;

    Doesn't blow up:

    EXEC sp_executesql @Sql, @Parms,

    @IdParam = @Id,

    @IdParam2 = @TransactionId,

    @DataValue = @FieldDataValue OUTPUT,

    @Result = @ResultFrom OUTPUT

    WITH RESULT SETS

    ((

    [Sql] nvarchar(1000),

    Parms nvarchar(500),

    IdParam uniqueidentifier,

    IdParam2 uniqueidentifier,

    DataValue BIT,

    Result BIT

    ))

    ;

    The part that I find to be a little frustrating, is that the data types for the parameters defined for WITH RESULT SETS are defined elsewhere in the SP to begin with..... But I guess I'm just complaining. And probably still don't fully understand what the newer metadata gathering functionality actually buys (big picture). As it relates to me on this day though, it sucks.

    Thanks again for your help, I really appreciate you taking time to respond.