Hi.

I am Sorry that I don't know how to ask question for my Scenario. Thats why I just used "How to update qty into table2
from table1? "

This is the scenario of one of my customer
Table-1 Subscription Master(News Paper) - Received Subscription

    CustCode  Name  Copies      date           Agent
    0001        XXX    10       10.05.2015       AKL            
    0001        XXX     5       15.05.2015       AKL    
    0001        XXX     7       18.05.2015       AKL

System has to instruct the Agent for delivery just like below
So I insert data from Table-1 to table-2
Using below code

INSERT INTO  [dbo.Table-2] ( Custcode,Copies,Date,Agent)  
SELECT  CustCode,Copies,Date,Agent FROM  [dbo.table-1]

Result is like below

0001    10  10.05.2015  AKL         
0001    5   15.05.2015  AKL 
0001    7   18.05.2015  AKL

And I have try to update Qty using below code

UPDATE  [dbo.Table-1]    SET Copies = (SELECT SUM(B.Copies) FROM [dbo.Table-1] AS b 
WHERE B.custcode = [dbo.Table-1].CustCode AND B.Date = [dbo.Table-1].date)

But there is no change
But I need like below to report for delivery
Tabe-2 DeliveryTable_Agent

CustCode  Copies    date        Agent
0001      10    10.05.2015  AKL
0001      10    11.05.2015  AKL
0001      10    12.05.2015  AKL
0001      10    13.05.2015  AKL
0001      10    14.05.2015  AKL
0001      15    15.05.2015  AKL
0001      15    16.05.2015  AKL
0001      15    17.05.2015  AKL
0001      22    18.05.2015  AKL
0001      22    19.05.2015  AKL
0001      22    20.05.2015  AKL

and so on

How can do this.
Pls advice me

Maideen

I am consfused as you say you want to update table 2 from table 1 but your query that isn't working is updating table 1 from table 1. Please clarify which table it is you need to update

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.