The previous section gave us an insight into how to create modules and show them on view. When compared to views that simply project data, stored procedures are very powerful modules that are also used for data projection. But the biggest strength of stored procedures arises when we either need to optimize difficult queries or when we want to manipulate data. Let's go straight into creating our first stored procedure now. We will still use the denormalization example from the previous sections, but we will encapsulate it into a stored procedure.
The following script demonstrates this:
CREATE OR ALTER PROC Staging.procLoadOrdersAS DELETE Analytics.OrdersINSERT Analytics.Orders (OrderLineId, ProductKey, ProductName, ...