I have the following data in which I have duration and predecessors for my activities. Now I want to calculate the start and end date of activities with reference to their predecessors. The data is sampled below. Also please note there might be activities which may not have predecessors so their start date should be @startDate and end date should be calculated from their duration and sundays should be excluded.

Given the initial begin date (@BeginDate), and assuming the tasks are executed sequentially by taskid, I should be able to calculate a begin and end date for each task, resulting in something like this:

Since you give us next to nothing to work with, this is what you should expect.

I'm risking another guess at, what I have understood, you are trying to attempt (hmm you actually didn't show us your attempt, so this is just me guessing ... again):

declare @startDate date='2019-03-11';
with cte_dates
as (select top(1) with ties
a.dt
,-1+row_number() over(order by a.dt) as daynum
from (select top(1) with ties
dateadd(day,-1+row_number() over(order by (select null)),@startdate) as dt
,case when datediff(day,0,dateadd(day,-1+row_number() over(order by (select null)),@startdate))%7=6 then 1 else 0 end as exclude
from (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally1(n)
cross apply (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally2(n)
cross apply (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally3(n)
order by exclude
) as a
cross apply (select sum(duration) as duration
from yourtable
) as b
order by case when row_number() over(order by a.dt)<=b.duration then 0 else 1 end
)
,cte_sequence
as (select actid
,1 as rn
from yourtable
where predecessor is null
union all
select a.actid
,b.rn+1
from yourtable as a
inner join cte_sequence as b
on b.actid=a.predecessor
)
,cte_dateno
as (select a.actid
,b.actname
,b.duration
,b.predecessor
,sum(b.duration) over(order by a.rn
rows unbounded preceding
)
-b.duration
as dayfrom
,sum(b.duration) over(order by a.rn
rows unbounded preceding
)
as dayto
from cte_sequence as a
inner join yourtable as b
on b.actid=a.actid
)
select a.actid
,a.actname
,a.duration
,a.predecessor
,min(b.dt) as startdate
,max(b.dt) as enddate
from cte_dateno as a
inner join cte_dates as b
on b.daynum>=a.dayfrom
and b.daynum<a.dayto
group by a.actid
,a.actname
,a.duration
,a.predecessor
order by startdate
;

declare @startDate date='2019-03-11'; with cte_dates as (select top(1) with ties a.dt ,-1+row_number() over(order by a.dt) as daynum from (select top(1) with ties dateadd(day,-1+row_number() over(order by (select null)),@startdate) as dt ,case when datediff(day,0,dateadd(day,-1+row_number() over(order by (select null)),@startdate))%7=6 then 1 else 0 end as exclude from (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally1(n) cross apply (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally2(n) cross apply (values(0),(0),(0),(0),(0),(0),(0),(0),(0),(0)) as tally3(n) order by exclude ) as a cross apply (select sum(duration) as duration from yourtable ) as b order by case when row_number() over(order by a.dt)<=b.duration then 0 else 1 end ) ,cte_sequence as (select actid ,1 as rn from yourtable where predecessor is null union all select a.actid ,b.rn+1 from yourtable as a inner join cte_sequence as b on b.actid=a.predecessor ) ,cte_dateno as (select a.actid ,b.actname ,b.duration ,b.predecessor ,sum(b.duration) over(order by a.rn rows unbounded preceding ) -b.duration as dayfrom ,sum(b.duration) over(order by a.rn rows unbounded preceding ) as dayto from cte_sequence as a inner join yourtable as b on b.actid=a.actid ) select a.actid ,a.actname ,a.duration ,a.predecessor ,min(b.dt) as startdate ,max(b.dt) as enddate from cte_dateno as a inner join cte_dates as b on b.daynum>=a.dayfrom and b.daynum<a.dayto group by a.actid ,a.actname ,a.duration ,a.predecessor order by startdate

You are not calculating the activity start date from its predecessor, you are calculating it from its previous line record which is against standard predecessor law.
For Example: If on row 2 we have defined predecessor 10 then you it should calculate the 10th predecessor activity's start and end date then get back to row 2 and manipulate its start and end date.

You are not calculating the activity start date from its predecessor, you are calculating it from its previous line record which is against standard predecessor law.
For Example: If on row 2 we have defined predecessor 10 then you it should calculate the 10th predecessor activity's start and end date then get back to row 2 and manipulate its start and end date.