Function multiple outputs, multiple inputs?

  • Right first post so bear with me!

    I have a query that I would like to turn into a function, the query needs to output multiple columns.

    The output of this function would then be used in a select query.

    So basically I want to select from table A a transid, pass this to the function which will then output a number of fields.

    Now I know that I can create a table function but the problem with that is how do I pass multiple transid's into it?

    Or do I need to use a scalar function? but then how do I return more than one value?!

    Erm I hope that I've explained it ok! any help more than appreciated!

  • have a look at cross apply.

    You can call a function for each row of a resultset and return a resultset.

    Not sure that's what you want to do but sounds something like it.


    Cursors never.
    DTS - only when needed and never to control.

  • Are you sure this isn't a join you need to make?

    It's hard to say what you need without more information. As Nigel mentioned, cross apply might do what you want, but it might not be the most efficient way to do things. If you can post some sample DDL/data, we can help you decide what makes sense.

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

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