Quantcast
Channel: SQL Server Database Engine forum
Viewing all articles
Browse latest Browse all 12963

per day cumulative stock

$
0
0

Hi Everyone,

here I'm trying to findout the per day stock on the basis of below code but the code is not running its giving the error 

please anyone help me to correct this code is it right way or not which is I'm trying.

        

 create table Stock

   (
    [Item No_] int,
    [Location Code] nvarchar(155),
    Stock decimal(30),
    [Posting Date] DATE
    );

    SELECT * FROM Stock

    DECLARE  @date1 DATETIME;
    set @date1 = '2013-12-01'
    while @date1 <= '2013-12-31'
    (
     insert into Stock 
     select  [Item No_],[Location Code],sum([Quantity])as Stock, @date1 as [Posting Date]
     from [bckup].[dbo].[ItemLedgerEntry]
     where [Posting Date]<= @date1
     set @date1 = dateadd(day,1,@date1)
     )


Viewing all articles
Browse latest Browse all 12963

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>