Log in
::
Register
::
Not logged in
Home
Tags
Articles
Editorials
Stairways
Forums
Scripts
Videos
Blogs
QotD
Books
Ask SSC
SQL Jobs
Training
Authors
About us
Contact us
Newsletters
Write for us
Recent Posts
Recent Posts
Popular Topics
Popular Topics
Home
Search
Members
Calendar
Who's On
Home
»
SQL Server 2005
»
Development
»
Function multiple outputs, multiple inputs?
Function multiple outputs, multiple inputs?
Rate Topic
Display Mode
Topic Options
Author
Message
n3ild
n3ild
Posted Tuesday, December 07, 2010 7:25 AM
Forum Newbie
Group: General Forum Members
Last Login: Tuesday, May 21, 2013 8:47 AM
Points: 3,
Visits: 127
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
nigelrivett
nigelrivett
Posted Tuesday, December 07, 2010 7:32 AM
Old Hand
Group: General Forum Members
Last Login: Monday, January 28, 2013 1:45 AM
Points: 386,
Visits: 199
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
Steve Jones - SSC Editor
Steve Jones - SSC Editor
Posted Tuesday, December 07, 2010 7:43 AM
SSC-Dedicated
Group: Administrators
Last Login: Today @ 1:14 AM
Points: 31,433,
Visits: 13,746
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 »
Permissions
You
cannot
post new topics.
You
cannot
post topic replies.
You
cannot
post new polls.
You
cannot
post replies to polls.
You
cannot
edit your own topics.
You
cannot
delete your own topics.
You
cannot
edit other topics.
You
cannot
delete other topics.
You
cannot
edit your own posts.
You
cannot
edit other posts.
You
cannot
delete your own posts.
You
cannot
delete other posts.
You
cannot
post events.
You
cannot
edit your own events.
You
cannot
edit other events.
You
cannot
delete your own events.
You
cannot
delete other events.
You
cannot
send private messages.
You
cannot
send emails.
You
may
read topics.
You
cannot
rate topics.
You
cannot
vote within polls.
You
cannot
upload attachments.
You
may
download attachments.
You
cannot
post HTML code.
You
cannot
edit HTML code.
You
cannot
post IFCode.
You
cannot
post JavaScript.
You
cannot
post EmotIcons.
You
cannot
post or upload images.
Copyright © 2002-2013 Simple Talk Publishing. All Rights Reserved.
Privacy Policy.
Terms of Use.
Report Abuse.