Write up an SQL Query to do the following:
There's 2 databases: a source and destination. The destination DB has a a table called ArticleWidths & ArticleSizes, where it stores all the sizes and widths of an article.
The source DB has another table called Item_Location, that contains the inventory for all articles.
The stored proc's job is to go through each record in the ArticleWidths table and check if there's stock available on the ItemLocation. If no stock, then we shall remove the corresponding record on ArticleWidth & ArticleSizes. The converse is also true, i.e. if there's stock available on ItemLocation for a specific size/width, you will insert the record on both ArticleSize and ArticleWidth.
The ItemLocation table has an ItemID, 10-digit varchar which matches the ArticleWidth ItemID.
ItemLocation has ItemID, StoreID, StockOnHand, LayawayQty
There's a 1:1 relationship between ItemLocation & ArticleWidths, but NOT necessarily all records in ItemLocation exists in ArticleWidths and vice-verse