create function return_fac_count (@PROD_SMALL_KIND_ID int, @PROD_FAC_ID int) returns intasbegin return (Select count (*) as prod_count FROM PROD_SUMMARY_INFO AS S, PROD_PRICE AS P, FAC_INFO AS N WHERE N.FAC_INFO_ID = S.PROD_FAC_ID AND S.ISENABLE = 1 AND S.is_visible = 1 and s.prod_id = p.Prod_id and s.prod_small_kind_id = @PrOd_small_kind_id and sprodu_fac_id=@prod_fac_id) end