• Yes, a Multistatement TVF (as opposed to an Inline one like I had tried earlier, or even a View) seems to work.

    So first this:

    CREATE FUNCTION dbo.TestWrapper()

    RETURNS @Temp TABLE (IntVal INT)

    BEGIN

    INSERT INTO @Temp (IntVal)

    SELECT IntVal

    FROM SQL#.Util_GenerateInts(1, 4, 1)

    RETURN

    END

    and then this should work:

    DECLARE @Table TABLE (IntVal INT NOT NULL)

    IF (1 = 0)

    BEGIN

    INSERT INTO @Table (IntVal)

    SELECT IntVal

    FROM dbo.TestWrapper()

    END

    However, if this is called repeatedly or if the CLR function returns a lot of rows, doing a Multistatement TVF could be inefficient. In that case you would be left with the Stored Procedure option.

    Hope that helps.

    Take care,

    Solomon...

    SQL#https://SQLsharp.com/ ( SQLCLR library ofover 340 Functions and Procedures)
    Sql Quantum Lifthttps://SqlQuantumLift.com/ ( company )
    Sql Quantum Leaphttps://SqlQuantumLeap.com/ ( blog )
    Info sitesCollations     •     Module Signing     •     SQLCLR