Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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
SQL
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

SQL
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
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900