4,707 questions
If you have a large number of rows to be processed, you should use a number table to assist your query.
If you just have a few rows, you can even use recursive to get your result on the fly.
declare @CID int=122, @S_no int =5
;with mycte as (
select @CID CID,1 as S_no
union all
Select CID, S_no+1 as S_no
from mycte where S_no<@S_no)
Insert into #tbl_ContD(CID,S_no)
select CID,S_no from mycte