- May 18, 2001
- 7,881
- 378
- 126
Suppose I have a SQL Server table named 'gadget'. 'gadget' has an integer field named 'gadget_key', which is the primary key of the table.
Now suppose I have a user-defined function named 'udf_gadget_values'. This function takes as its input parameter an integer variable named '@nGadgetKey'. This function returns a table which will always contain exactly one record. This one record has one field named 'nGadgetKey', which contains the same value that was passed to the function in parameter '@nGadgetKey'
I would like to join the table 'gadget' with the table that function 'udf_gadget_values' returns kind of like this:
SELECT TOP 10 *
FROM gadget, udf_gadget_values(gadget.gadget_key)
The purpose of this query is to get the top 10 records from 'gadget', as well as the values associated with each record, as returned by the function.
Anything goes (i.e. if the function needs to be modified, then so be it). If anyone can give a good idea about how to do this, then they get a :beer: or two from me.
Now suppose I have a user-defined function named 'udf_gadget_values'. This function takes as its input parameter an integer variable named '@nGadgetKey'. This function returns a table which will always contain exactly one record. This one record has one field named 'nGadgetKey', which contains the same value that was passed to the function in parameter '@nGadgetKey'
I would like to join the table 'gadget' with the table that function 'udf_gadget_values' returns kind of like this:
SELECT TOP 10 *
FROM gadget, udf_gadget_values(gadget.gadget_key)
The purpose of this query is to get the top 10 records from 'gadget', as well as the values associated with each record, as returned by the function.
Anything goes (i.e. if the function needs to be modified, then so be it). If anyone can give a good idea about how to do this, then they get a :beer: or two from me.