@sknav ,
STRING_AGG()
function could be handy for your scenario. It will work starting from SQL Server 2017 onwards.
Check it out here: string-agg-transact-sql
Along the following:
declare @IDs nvarchar(max);
select @IDs = STRING_AGG(CAST(SS.[Id] AS VARCHAR(10)), ',')
from stockmanager.Stock SS
inner join stockmanager.StockStatus SSS on SS.StockStatusId=SSS.Id
inner join stockmanager.StockStore SST on SS.Id=SST.StockId
inner join storedatabase.Store SDS on SST.StoreId=SDS.Id
where SSS.Id=2 and SST.StoreId=124;