Latest Real 70-461 Tests Dumps and VCE Exam Questions 11-20

Ensurepass

QUESTION 11

You develop a Microsoft SQL Server 2012 database. You create a view from the Orders and OrderDetails tables by using the following definition.

 

clip_image001

 

You need to ensure that users are able to modify data by using the view. What should you do?

 

A.      Create an AFTER trigger on the view.

B.      Modify the view to use the WITH VIEW_METADATA clause.

C.      Create an INSTEAD OF trigger on the view.

D.      Modify the view to an indexed view.

 

Correct Answer: C

 

 

QUESTION 12

You have a view that was created by using the following code:

 

clip_image002

 

You need to create an inline table-valued function named Sales.fn_OrdersByTerritory, which must meet the following requirements:

 

Ÿ   Accept the @T integer parameter.

Ÿ   Use one-part names to reference columns.

Ÿ   Filter the query results by SalesTerritoryID.

Ÿ   Return the columns in the same order as the order used in OrdersByTerritoryView.

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)

RETURNS TABLE

AS

RETURN

(

    SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue

    FROM Sales.OrdersByTerritory

    WHERE SalesTerritoryID = @T

)

 

 

QUESTION 13

You have a database that contains the tables shown in the exhibit.

 

clip_image003

 

You deploy a new server that has SQL Server 2012 installed. You need to create a table named Sales.OrderDetails on the new server. Sales.OrderDetails must meet the following requirements:

 

Ÿ   Write the results to a disk.

Ÿ   Contain a new column named LineItemTotal that stores the product of ListPrice and Quantity for each row.

Ÿ   The code must NOT use any object delimiters.

 

The solution must ensure that LineItemTotal is stored as the last column in the table. Which code segment should you use?

 

To answer, type the correct code in the answer area.

Correct Answer:

CREATE TABLE Sales.OrderDetails (

ListPrice money not null,

Quantity int not null,

LineItemTotal as (ListPrice * Quantity) PERSISTED)

 

 

QUESTION 14

You have a database that contains the tables shown in the exhibit.

 

clip_image004

 

You need to create a view named uv_CustomerFullName to meet the following requirements:

 

Ÿ   The code must NOT include object delimiters.

Ÿ   The view must be created in the Sales schema.

Ÿ   Columns must only be referenced by using one-part names.

Ÿ   The view must return the first name and the last name of all customers.

Ÿ   The view must prevent the underlying structure of the customer table from being changed.

Ÿ   The view must be able to resolve all referenced objects, regardless of the user’s default schema.

 

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

CREATE VIEW Sales.uv_CustomerFullName

WITH SCHEMABINDING

AS

SELECT FirstName, LastName

FROM Sales.Customers

 

 

QUESTION 15

You have a database that contains the tables shown in the exhibit.

 

clip_image005

You need to create a query that calculates the total sales of each OrderId from the Sales.Details table. The solution must meet the following requirements:

 

Ÿ   Use one-part names to reference columns.

Ÿ   Sort the order of the results from OrderId.

Ÿ   NOT depend on the default schema of a user.

Ÿ   Use an alias of TotalSales for the calculated ExtendedAmount.

Ÿ   Display only the OrderId column and the calculated TotalSales column.

 

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

SELECT OrderID, SUM(ExtendedAmount) AS TotalSales

FROM Sales.Details

GROUP BY OrderID

ORDER BY OrderID

 

 

QUESTION 16

You have a database that contains the tables as shown in the exhibit.

 

clip_image006

 

You have the following query:

 

clip_image007

 

You need to recreate the query to meet the following requirements:

 

Ÿ   Reference columns by using one-part names only.

Ÿ   Sort aggregates by SalesTerritoryID, and then by ProductID.

Ÿ   Order the results in descending order from SalesTerritoryID to ProductID.

Ÿ   The solution must use the existing SELECT clause and FROM clause.

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

SELECT SalesTerritoryID,

ProductID,

AVG(UnitPrice),

MAX(OrderQty),

MAX(DiscountAmount)

FROM Sales.Details

GROUP BY SalesTerritoryID , ProductID

ORDER BY SalesTerritoryID DESC, ProductID DESC

 

 

QUESTION 17

You have a database that contains the tables shown in the exhibit.

 

clip_image008

 

You need to create a query for a report. The query must meet the following requirements:

 

Ÿ   NOT use object delimiters.

Ÿ   Return the most recent orders first.

Ÿ   Use the first initial of the table as an alias.

Ÿ   Return the most recent order date for each customer.

Ÿ   Retrieve the last name of the person who placed the order.

Ÿ   Return the order date in a column named MostRecentOrderDate that appears as the last column in the report.

 

The solution must support the ANSI SQL-99 standard. Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

SELECT C.LastName, MAX(O.OrderDate) AS MostRecentOrderDate

FROM Customers AS C INNER JOIN Orders AS O

ON C.CustomerID = O.CustomerID

GROUP BY C.LastName

ORDER BY O.OrderDate DESC

 

 

QUESTION 18

You have an XML schema collection named Sales.InvoiceSchema. You need to declare a variable of the XML type named XML1. The solution must ensure that XML1 is validated by using Sales.InvoiceSchema. Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

DECLARE @XML1 XML(Sales.InvoiceSchema)

 

 

QUESTION 19

You have a database that contains the tables as shown in the exhibit.

 

clip_image009

 

You need to create a query that returns a list of products from Sales.ProductCatalog. The solution must meet the following requirements:

 

Ÿ   UnitPrice must be returned in descending order.

Ÿ   The query must use two-part names to reference the table.

Ÿ   The query must use the RANK function to calculate the results.

Ÿ   The query must return the ranking of rows in a column named PriceRank.

Ÿ   The list must display the columns in the order that they are defined in the table.

Ÿ   PriceRank must appear last.

 

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

 

SELECT ProductCatalog.CatID, ProductCatalog.CatName, ProductCatalog.ProductID, ProductCatalog.ProdName, ProductCatalog.UnitPrice,

RANK() OVER (PARTITION BY ProductCatalog.UnitPrice ORDER BY ProductCatalog.UnitPrice DESC) AS PriceRank

FROM Sales.ProductCatalog

ORDER BY ProductCatalog.UnitPrice DESC

 

 

QUESTION 20

You have a database that contains the tables shown in the exhibit.

 

clip_image010

 

You have an application named Appl. You have a parameter named @Count that uses the int data type. App1 is configured to pass @Count to a stored procedure. You need to create a stored procedure named usp_Customers for Appl. Usp_Customers must meet the following requirements:

 

Ÿ   NOT use object delimiters.

Ÿ   Minimize sorting and counting.

Ÿ   Return only the last name of each customer in alphabetical order.

Ÿ   Return only the number of rows specified by the @Count parameter.

Ÿ   The solution must NOT use BEGIN and END statements.

 

Which code segment should you use?

 

To answer, type the correct code in the answer area.

 

Correct Answer:

CREATE PROCEDURE usp_Customers @Count int

AS

SELECT TOP(@Count) Customers.LastName

FROM Customers

ORDER BY Customers.LastName

 

 

 

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.