The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 3 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
I need help with these questions and am using SQL with the adventurework2012 database.
1. Reimplement the spTriangular function from Chapter 12 as a function instead of as a stored procedure. (Query is attached)
2. Create a function that takes as inputs a SalesOrderID, a CurrencyCode, and a date, and returns
a table of all the SalesOrderDetail rows for that Sales Order including Quantity, ProductID,
UnitPrice, and the unit price converted to the target currency based on the end of day rate for
the date provided. Exchange rates can be found in the Sales.CurrencyRate table
Â
Â
ALTER PROC spTriangular @ValueIn int, @ValueOut int OUTPUT AS DECLARE @InWorking int; DECLARE @OutWorking int; IF @ValueIn > 32 BEGIN THROW 50001, 'Overflow! Input value should not be greater than 32', 1; RETURN; END IF @ValueIn != 1 BEGIN SELECT @InWorking = @ValueIn - 1; EXEC spTriangular @InWorking, @OutWorking OUTPUT; SELECT @ValueOut = @ValueIn + @OutWorking; END ELSE BEGIN SELECT @ValueOut = 1; END RETURN; GO
Attachments:
-----------