EMartinez
3/27/2007 12:52:00 AM
On Mar 26, 9:01 am, "Calvin Willman" <a...@anon.com-no-spam> wrote:
> Thanks Enrique,
>
> You're right, I was trying to cut corners I think here... but the
> Multi-Statement Function is the one I'm after.
>
> "EMartinez" <emartinez....@gmail.com> wrote in message
>
> news:1174908732.475129.109500@y80g2000hsf.googlegroups.com...
>
> > On Mar 26, 6:11 am, "Calvin Willman" <a...@anon.com-no-spam> wrote:
> >> ALTER FUNCTION [dbo].[fn_KPI_GET_EXCL_PRODUCTS]
>
> >> (
>
> >> @CustomerID int
>
> >> )
>
> >> RETURNS TABLE
>
> >> AS RETURN (
>
> >> IF (SELECT COUNT(ProductCode) from dbo.KPI_PROD_CDE_EXCL AS ProductCode
> >> WHERE CustomerID = @CustomerID) > 0
>
> >> BEGIN
>
> >> SELECT ProductCode from dbo.KPI_PROD_CDE_EXCL AS ProductCode WHERE
> >> CustomerID = @CustomerID
>
> >> END
>
> >> ELSE
>
> >> BEGIN
>
> >> SELECT ProductCode from dbo.KPI_PROD_CDE_EXCL AS ProductCode WHERE
> >> CustomerID = @CustomerID
>
> >> END
>
> >> )
>
> > If my memory serves me correctly, I don't believe that you can include
> > conditional statements in inline, table-valued functions. Look into
> > using a multi-statement function instead. Hope this helps.
>
> > Regards,
>
> > Enrique Martinez
> > Sr. Software Consultant
You're welcome. Glad I could be of assistance.
Regards,
Enrique Martinez
Sr. Software Consultant