SQL query to break down parent item to child item

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! ##-----------------------------------------------##

Reply to
raygorcha
Loading thread data ...

BeanSmart website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.