Re: Returning table from UDF

Tech-Archive recommends: Speed Up your PC by fixing your registry

From: Y.Makarounis (ymak_at_otenet.gr)
Date: 01/22/05


Date: Sat, 22 Jan 2005 11:11:24 +0200

Thank you David

My problem is the following:
I have certain tables to which apart from a standard number of fields
additional fields are added depending on customer requirements. A "Select *
>From Table_A" statement returns all fields but because there are several
versions of the same record in the table some quite elaborate filtering
(based on current criteria) is needed to get a single record. This results
in cubersome queries. So I was wondering if I could write a UDF which would
"hide" all the complication and call it as "Select * From
UDF_A(param1,param2,..)"?
What I already have done is write a UDF returning as a table the Ids of the
records satisfying the criteria and then using that to filter the original
table ie
"Select * From Table_A where Table_A.Id IN (Select Id From UDF_X(params))"
but it is still a litle complicated for "report writers" who don't know the
internals.

Yannis

"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:nbidnZWNSYMQ_2zcRVn-jA@giganews.com...
> No. Stored procedures can return variable numbers of columns though.
That's
> not to say that dynamic result sets from an SP is necessarily a good way
to
> accomplish things. Maybe if you describe your problem we can suggest a
> solution.
>
> --
> David Portas
> SQL Server MVP
> --
>
>



Relevant Pages

  • Re: Returning table from UDF
    ... A UDF has only one returned set. ... > versions of the same record in the table some quite elaborate filtering ... > (based on current criteria) is needed to get a single record. ...
    (microsoft.public.sqlserver.programming)
  • UDF for Sumproduct
    ... I'm trying to create a UDF for sumproduct that will be dynamic on the numbers ... uses a defined range and offsets from that rage to get ... the criteria ranges and sumrange. ...
    (microsoft.public.excel.programming)
  • Re: countif based on fill color
    ... Not possible with built in functions unless you can use the criteria which made you colour them in the first place, otherwise you will need code, either a macro or a UDF ... count all cells I've filled in red. ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Using DGET to extract multiple records
    ... Bob wrote... ... function or UDF). ... Something like the following to get the _i_th row mathcing your ... Criteria is a placeholder for the criteria expression you want ...
    (microsoft.public.excel.worksheet.functions)