SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Function multiple outputs, multiple inputs?


Function multiple outputs, multiple inputs?

Author
Message
n3ild
n3ild
Forum Newbie
Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)Forum Newbie (5 reputation)

Group: General Forum Members
Points: 5 Visits: 184
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!
nigelrivett
nigelrivett
SSC-Addicted
SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)SSC-Addicted (480 reputation)

Group: General Forum Members
Points: 480 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.

Steve Jones
Steve Jones
SSC Guru
SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)SSC Guru (62K reputation)

Group: Administrators
Points: 62242 Visits: 19102
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
My Blog: www.voiceofthedba.com
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search