What should you do?

HOTSPOT
This is a case study. Case studies are not timed separately. You can use as much exam time as you would like to complete each case. However, there may be additional case studies and sections on this exam. You must manage your time to ensure that you are able to complete all questions included on this exam in the time provided.
To answer the questions included in a case study, you will need to reference information that is provided in the case study. Case studies might contain exhibits and other resources that provide more information about the scenario that is described in the case study. Each question is independent of the other questions in this case study.
At the end of this case study, a review scree will appear. This screen allows you to review your answers and to make changes before you move to the next section of the exam. After you begin a new section, you cannot return to this section.
To start the case study
To display the first question in this case study, click the Next button. Use the buttons in the left pane to explore the content of the case study before you answer the questions. Clicking these buttons displays information such as business requirements. Existing environment, and problem statements. If the case study has an
All Information tab, note that the information displayed is identical to the information displayed on the subsequent tabs. When you are ready to answer a question, click the Question button to return to the question.
Background
You have a database named Sales.
The Customer table includes a column that stores the date for the last order that the customer placed.
You plan to create a table named Leads. The Leads table is expected to contain approximately 20,000 records. Storage requirements for the Leads table must be minimized.
Tables

You need to implement a stored procedure that deletes a discontinued product from the Products table. You identify the following requirements:
If an open order includes a discontinued product, the records for the product must not be deleted.
The stored procedure must display a custom error message if a product record cannot be deleted. The message must identify the OrderID for the open order.
What should you do? To answer, select the appropriate Transact-SQL segments in the answer area.
Hot Area:

microsoft-exams

One thought on “What should you do?

  1. CREATE PROCEDURE THROWERROR AS
    BEGIN

    BEGIN TRY
    DECLARE @OrderId INT;
    SELECT @OrderId = 145 –The id of the order referencing a product that has been discontinued
    IF(@OrderId IS NOT NULL)
    BEGIN

    RAISERROR(‘Error in row %d’,16,1,@OrderId);
    END
    END TRY
    BEGIN CATCH
    IF(@@TRANCOUNT>0)
    ROLLBACK;
    THROW;
    END CATCH

    END
    GO
    exec throwerror

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.