Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This uses Microsoft SQL Server and Adventure Works2012 Need help with #2 below (#1 is for reference) Create a simple stored procedure that does not

This uses Microsoft SQL Server and Adventure Works2012

Need help with #2 below (#1 is for reference)

  1. Create a simple stored procedure that does not expect any parameters and contains a single T-SQL statement.
    1. Create the stored procedure as PurchaseOrderInfo
    2. This stored Procedure should return a result set consisting of ProductName, PurchaseOrderID, PurchaseOrderDetailID, OrderDate, TotalDue and ReceivedQty.
    3. Refer to the schema AdventureWorks2012.Production and AdventureWorks2012.Purchasing to access the necessary tables needed to generate the following output.
    4. EXECUTE the stored procedure in 2 ways.
      1. Using the simple EXECUTE keyword, and
      2. Using EXECUTE command by adding a WITH RESULT SETS statement.
    5. Show the CREATE PROC, both the EXECUTE statements and the two sets of result sets in the screenshot.
    6. The result should yield 8845 records as shown below in both screenshots.
  2. ALTER the above stored procedure using input and default parameters.
    1. Write the ALTER procedure for PurchaseOrderInfo
    2. Add two parameters: ALTER PROCEDURE [dbo].[PurchaseOrderInfo]

@EmployeeID int, -- input parameter

@OrderYear int = 2005 -- default parameter

  1. Next add a criteria to your T-SQL statement in your procedure to limit the result based on the values of the two parameters.

poh.EmployeeID = @EmployeeID

AND YEAR(poh.OrderDate) = @OrderYear

  1. This altered stored procedure should execute successfully.
  2. Now, EXECUTE the stored procedure by passing 258 for the input parameter and 2006 for default parameter.
  3. Show the ALTER PROC, EXEC statement with the two passing parameters and the result screenshot.
  4. The result should yield 45 records as shown below. (Note: You should get records for every order date placed in 2006.)

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

Step: 3

blur-text-image

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

Beginning VB 2008 Databases

Authors: Vidya Vrat Agarwal, James Huddleston

1st Edition

1590599470, 978-1590599471

More Books

Students also viewed these Databases questions

Question

What is digital literacy? Why is it necessary?

Answered: 1 week ago