SQL query to break down parent item to child item

Apr 30, 2010 0 Replies

I wants to create a SQL query to break all parent item into child item when run.



please advice..



I have something here but seems not working, could someone help to create this?



Thanks.


create view vparent as select i.id, i.itemlookupcode as ParentILC, i.quantity as ParentInstock, from item i where i.id in (select parentitem from item where parentitem = 0)



create view vchild as select i.itemlookupcode, i.description, vparent.ParentInstock * i.parentquantity as ParentQty, cast(vparent.ParentInstock * i.parentquantity as ParentQty) as CalculatedQTY from item i INNER JOIN VPARENT ON i.PARENTITEM = ParentInstock.ID where i.parentitem > 0



update item set quantity = i.quantity + vchild.CalculatedQTY where i.parentitem 0 update item set quantity = 0 where i.parentitem = 0


-------------------------------------


##-----------------------------------------------## Newsgroup Access Courtesy

formatting link
Tax and Accounting Software ForumsWeb and RSS access to your favorite newsgroup - microsoft.public.pos - 40354 messages and counting! ##-----------------------------------------------##


Join the Discussion

Have something to add? Share your thoughts — no account required.

Didn't find your answer?

Ask the community — no account required