I have a function which name is fnc_FiderSumOfAboneSayisi that can be sent an integer value with parameter @prm_fiderid. so I have a table which name is fider_data that has ID column. Now I want to in order to send fider_data ID column value as parameter to my fnc_FiderSumOfAboneSayisi function as a loop.
how can i do that ??
----------FUNCTION
alter function fnc_FiderSumOfAboneSayisi @prm_fiderid as int
returns int
as
begin
declare @parent int = @prm_fiderid;
declare @SUM int;
with q As(
select * from fider_data where ParentId = @parent union all select lc.* from q join fider_data lc on lc.ParentId = q.ID )SELECT @SUM=(SELECT sum(SAYI) FROM q where ID<33000) return @SUM
end
----------TABLE fider_data
ADI ID
TM 1 1
TM 2 2
TM 3 3
TM 4 4
TM 5 5
TM 6 6
TM 7 7
TM 8 8
TM 9 9
.
.
.