I have a UDF that returns a table data type by recursion. The UDF takes a
two input parameters. Can I call the UDF within a Select statement?
i.e.
SELECT dbo.GetTable(col2,1)
FROM table
"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
>I have a UDF that returns a table data type by recursion. The UDF takes a
> two input parameters. Can I call the UDF within a Select statement?
> i.e.
> SELECT dbo.GetTable(col2,1)
> FROM table
If you are passing a column value into the UDF you must use the new (SQL
2005) APPLY operator
SELECT t.whatever, gt.*
FROM table t
CROSS APPLY dbo.GetTable(col2,1) gt
David
|||David,
Does this apply only to CLR functions?
-- Bill
"David Browne" <davidbaxterbrowne no potted meat@.hotmail.com> wrote in
message news:eG9QJ7JTHHA.3428@.TK2MSFTNGP04.phx.gbl...
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>
|||Thanks,
So, is there a method or workaround for doing this in SQL Server 2000?
"David Browne" wrote:
>
> "Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
> news:DA800CC3-27DD-4003-B337-8B4C990B3A7E@.microsoft.com...
> If you are passing a column value into the UDF you must use the new (SQL
> 2005) APPLY operator
> SELECT t.whatever, gt.*
> FROM table t
> CROSS APPLY dbo.GetTable(col2,1) gt
> David
>
>
|||"Tadwick" <Tadwick@.discussions.microsoft.com> wrote in message
news:C5C4903C-A9CA-4C80-8B8D-85E0C7C9A4AD@.microsoft.com...
> Thanks,
> So, is there a method or workaround for doing this in SQL Server 2000?
>
Not in the general case (thus the need to extend SQL). But if you have only
a few values for col2, you can perhaps use a cursor and a temp table to
construct the results.
David
|||"AlterEgo" <alterego55@.dslextreme.com> wrote in message
news:e7iqBLKTHHA.4756@.TK2MSFTNGP06.phx.gbl...
> David,
> Does this apply only to CLR functions?
>
No. All Table-Valued UDF's/.
David
Monday, March 19, 2012
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment