S
sandy
Dera all, i have created a UDF in SQL server and would to
call it using following SQL statement.
Any ideas how can i do that? The issues is that i can call
a UDF by specifiying the parameter etc.. but in this case,
i don't need to pass any parameters...since i am using UDF
in select statement.. i don't know how to call fill the
dataset in this case...
SELECT
B.BRAND_ID, SEGMENT_ID, B.LINE_ID,
DBO.GetDeliveryFeesF(B.BRAND_ID, SEGMENT_ID) AS
DELIVERYFEES
From Brand B
*****************************
create FUNCTION GetDeliveryFeesF ( @BrandID int, @segID
int )
RETURNS int
AS
BEGIN
RETURN(select
case
when b.chassis='Y' and deliveryfee is not null
then
b.DeliveryFee
Else
(Select isNull(sb.delivery_fee,
pl.delivery_fee) from brand b, Segment_Brand sb,
productline pl where sb.brand_id = b.brand_id AND
b.brand_id = @BrandID and sb.segment_id =@segID and
pl.line_id = b.line_id)
end As DeliveryFee
from brand b
where b.brand_id = @BrandID
)
END
***********************************************
call it using following SQL statement.
Any ideas how can i do that? The issues is that i can call
a UDF by specifiying the parameter etc.. but in this case,
i don't need to pass any parameters...since i am using UDF
in select statement.. i don't know how to call fill the
dataset in this case...
SELECT
B.BRAND_ID, SEGMENT_ID, B.LINE_ID,
DBO.GetDeliveryFeesF(B.BRAND_ID, SEGMENT_ID) AS
DELIVERYFEES
From Brand B
*****************************
create FUNCTION GetDeliveryFeesF ( @BrandID int, @segID
int )
RETURNS int
AS
BEGIN
RETURN(select
case
when b.chassis='Y' and deliveryfee is not null
then
b.DeliveryFee
Else
(Select isNull(sb.delivery_fee,
pl.delivery_fee) from brand b, Segment_Brand sb,
productline pl where sb.brand_id = b.brand_id AND
b.brand_id = @BrandID and sb.segment_id =@segID and
pl.line_id = b.line_id)
end As DeliveryFee
from brand b
where b.brand_id = @BrandID
)
END
***********************************************