Can this be a solution ?
declare @Article as varchar(15)
declare @Descrip as varchar(30)
declare @Stock as numeric
declare @Incoming as numeric
declare @Outgoing as numeric
declare @Monthly as numeric
declare @SalesPrice as numeric
declare @PurchasePrice as numeric
declare TableCursor_Stock cursor for
select codart,libel1, qtesto, month(now()), poids, priach
from vficart
where codfam like 'c%'
order by codart
set @month = month(now())
set @Stock = vficart.qtesto
set @SalesPrice = vficart.poids
open TableCursor_Stock
FETCH NEXT FROM TableCursor_Stock INTO @Artikelcode, @Stock, @month
WHILE @month <> '0'
BEGIN
do while @@FETCH_STATUS <> -1
@month = @month
@Out = select sum(quanti) from vligven where codart = @article and month(dtfact) = @month
@In = select sum(quanti) from vligach where codart = @article and month(dtfact) = @month
@Stock = @Stock + @In - @Out
@month = @month
--FETCH NEXT FROM TableCursor_Stock INTO @Article, @Stock, @In, @Out, @Month
insert into tbl_cml_stock
values (@Article, @Stock, @In, @Out, @Month, @Salesprice)
@month = @month-1
END
END
CLOSE TableCursor_NOBL
DEALLOCATE TableCursor_Stock
If yes, how do I get the results into an excel sheet ?
Kind regards
Jeffrey