Table valued functions - can the table definition differ based on parameters?

  • I was just wondering if the syntax for defining a table valued function allows for the function to return two different table schemas depending on the input... does anyone know if this is allowed/possible?

     

    Thanks,

     

    Paul

  • I don't think it is possible.

    MohammedU
    Microsoft SQL Server MVP

  • Not 100% sure.  But I'm 99.999999999999% sure it can't be done at the moment or ever for that matter.

     

    What problem are you trying to solve with this solution?

  • Thanks for the replies.

    I just want to know if I can assume the fields are going to be the same for table-valued functions because in one part of my UI all I need are the field names (not their values) and I want to delay binding the function to a parameter until later in the application.

    Paul

  • SET FMTONLY ON

    GO

    SELECT * FROM dbo.FnName ('Dummy value')

    GO

    SET FMTONLY OFF

     

     

    This will return the column names only without executing the Query.

Viewing 5 posts - 1 through 4 (of 4 total)

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