Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

If I have the following code, what alterations do I need to make to meet the requirements i,ii, & iii below. We have created our

If I have the following code, what alterations do I need to make to meet the requirements i,ii, & iii below. We have created our new database and I think this code from Create procedure through EXEC will do what I need for the assingment, but i'm just not sure. image text in transcribed

- You will modify this script so that the procedure accepts Start Date and End Dates as arguments or parameters and then generate all dates between the provided start and end dates. The start and end dates should NOT be hardcoded. In addition to generating the date, we will also generate month number and month name as well as year number and year name. Quarters do not need to be generated.The generated dates. Month, and years values will be used to populate the DimDatestable1 in your D_PubSales database. Your procedure should accomplish the following:

i.Check to see if DimDates1 table exists in D_PubSales database. If it exists, flush thae table and then repopulate it. If the table does not exist then create it. Its structure should be similar to DimDates but without the fields associated with quarters. ii. Next, the script should generate date values as specified above based on the start and end dates provided. Have the script insert these values into the DimDates1 table. iii. Finally, the procedure should retrieve all values in the DimDates1 table to demonstrate the script actually works and populates the DimDates1 table.

So my DimDates (original) looks like this: image text in transcribed

This is using SQL server.

Create procedure ap_PopulateFactSales AS BEGIN Insert into DWPubsales.dbo.FactSales (OrderNumber, SalesQuantity, OrderDateKey, StoreKey, TitleKey) (Select from dbo. Vw_selectdataforfactsales) END Select*From DWpubsales.dbo.factsales Delete from dwpubsales.dbo.factsales EXECUTE dbo.sp_populatefactsales Delete from Dimd ates exec dbo. sp_populatedimsales '01/01/2010" 02/15/2015 Create procedure ap_PopulateFactSales AS BEGIN Insert into DWPubsales.dbo.FactSales (OrderNumber, SalesQuantity, OrderDateKey, StoreKey, TitleKey) (Select from dbo. Vw_selectdataforfactsales) END Select*From DWpubsales.dbo.factsales Delete from dwpubsales.dbo.factsales EXECUTE dbo.sp_populatefactsales Delete from Dimd ates exec dbo. sp_populatedimsales '01/01/2010" 02/15/2015

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

SQL Antipatterns Avoiding The Pitfalls Of Database Programming

Authors: Bill Karwin

1st Edition

1680508989, 978-1680508987

More Books

Students also viewed these Databases questions