Passing empty TVPs

  • I have an inline table valued function (function1) where I need to call another inline function which requires 4 TVPs (function2).

    Unfortunately, given the limitations of my php calling program I cannot pass a TVP to function1. How can I make that call to function2 (using empty TVPs) from function1 without putting any TVP parameters on function1?

    I could do this by creating a multistatement wrapper function that declares the empty tables and passes them to function1, but I was trying to avoid doing this. Is there any other way?

    function1:

    ALTER FUNCTION [dbo].[function1] (

    @ListId INT,

    @StartSize INT = NULL,

    @EndSize INT = NULL,

    @StartDate DATE = NULL,

    @EndDate DATE = NULL

    )

    RETURNS TABLE

    --Want to call function2 with outer apply in this query

    function2:

    ALTER FUNCTION [dbo].[function2] (

    @Date DATE,

    @EarliestDate DATE,

    @LatestDate DATE,

    @params1 FLOAT,

    @param2 INT,

    @subst INT,

    @StateAbbrTable StateAbbr READONLY,

    @src SourceId READONLY,

    @LeadTable LeadId READONLY,

    @ProvisionTable ProvisionId READONLY

    )

    RETURNS TABLE

  • My solution ended up being to create a stored procedure as a wrapper where I declare the empty table parameters and run the TVF. I then added the parameters to function1 so that they can be passed to function2. It seems there is no way to accomplish this the way I was hoping.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply