Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Function multiple outputs, multiple inputs? Expand / Collapse
Author
Message
Posted Tuesday, December 7, 2010 7:25 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, September 18, 2014 3:50 AM
Points: 5, Visits: 177
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!
Post #1031208
Posted Tuesday, December 7, 2010 7:32 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Friday, December 13, 2013 4:35 AM
Points: 386, Visits: 211
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.
Post #1031211
Posted Tuesday, December 7, 2010 7:43 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: Administrators
Last Login: Today @ 11:18 AM
Points: 31,078, Visits: 15,522
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.







Follow me on Twitter: @way0utwest

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1031220
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse