Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
petersrj
Starting Member
20 Posts |
Posted - 2011-06-06 : 11:39:12
|
| I have written a custom function which takes in 5 parameters and returns a table after manipulating those input parameters. The function works correctly when run as follows:Select * from dbo.MyNewFunc(1, 2, 3, 4, 5)What I would like to do is to have the five parameters come from a select statement. Something like:Select * from dbo.MyNewFunc((Select Data1, Data2, Data3, Data4, Data5 from AnotherTable))When I try this I get than an insufficient number of arguements were supplied for the function. Is this possible? |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-06-06 : 12:19:13
|
What version of SQL Server are you in?Might work:Select A.Data1, A.Data2, A.Data3, A.Data4, A.Data5, B.*From AnotherTable ACross Apply dbo.MyNewFunc(Data1, Data2, Data3, Data4, Data5) BCorey I Has Returned!! |
 |
|
|
petersrj
Starting Member
20 Posts |
Posted - 2011-06-06 : 12:37:58
|
| Seventhnight, thanks you for your help. I am using SQL 2008 Express. Your suggestion worked perfectly on the first try. |
 |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2011-06-06 : 12:42:17
|
| If not using the Apply operator I believe you have to pass in the values as variables. |
 |
|
|
Seventhnight
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2011-06-06 : 13:33:10
|
Wow! A swing and a HIT! Corey I Has Returned!! |
 |
|
|
|
|
|
|
|