UDF with table parameter

  • Does exists what kind of trick to pass table variable to UDF?

    For example:

    declare @var table (x int)

    insert into @var select something from somewhere

    select dbo.myUDF(@var)

    Or it is possible to pass select statement as parameter?

    Toni.

  • Currently UDFs are limited to scalar parameters (ie, your plain vanilla data types). If you want to pass a statement, I would wonder why? Usually you just want to pass parameters in and use them in your already coded and tested statement.

    I doubt you can create a function that does what you want. SQL Server 2000 functions are still in their infancy and limited in what they can do.

  • I believe thou you can create a temp table instead liek

    CREATE TABLE #var (x int)

    and use a reference inside the UDF to #var. As long as in the same scope the table is visible to the UDF. But the question is what do you need to do exactly as you may be practicing overkill here.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply