Ensurepass.com Easy Test! Easy Pass!
Microsoft MCSA 70-461 Exam
Vendor:Microsoft
Exam Code: 70-461
Exam Name: Querying Microsoft SQL Server 2012
http://www.ensurepass.com/70-461.html
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 1
You administer a Microsoft SQL Server 2012 database named ContosoDB. Tables are defined as
shown in the exhibit.
You need to display rows from the Orders table for the Customers row having the CustomerId value
set to 1 in the following XML format:
<row OrderId="1" OrderDate="2000-01-01T00:00:00" Amount="3400.00" Name="Customer A"
Country="Australia" />
<row OrderId="2" OrderDate="2001-01-01T00:00:00" Amount="4300.00" Name="Customer A"
Country="Australia" />
Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
F. SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
G. SELECT Name AS '@Name', Country AS '@Country', OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH ('Customers')
H. SELECT Name AS 'Customers/Name', Country AS 'Customers/Country', OrderId, OrderDate,
Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH ('Customers')
Correct Answer: A
QUESTION 2
You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as
shown in the exhibit.
You need to display rows from the Orders table for the Customers row having the CustomerIdvalue
set to 1 in the following XML format.
Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers=CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO
F. SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
G. SELECT Name AS '@Name', Country AS '@Country', OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
H. SELECT Name AS 'Customers/Name', Country AS 'Customers/Country', OrderId, OrderDate,
Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
Correct Answer: C
QUESTION 3
You administer a Microsoft SQL Server 2012 database named ContosoDB. Tables are defined as
shown in the exhibit.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
You need to display rows from the Orders table for the Customers row having the CustomerId value
set to 1 in the following XML format.
<CUSTOMERS Name="Customer A" Country="Australia">
<ORDERS OrderID="1" OrderDate="2001-01-01" Amount="3400.00" />
<ORDERS OrderID="2" OrderDate="2002-01-01" Amount="4300.00" />
</CUSTOMERS>
Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId - Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO
F. SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
G. SELECT Name AS '@Name', Country AS '@Country', OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
H. SELECT Name AS 'Customers/Name', Country AS 'Customers/Country', OrderId, OrderDate,
Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
Correct Answer: E
QUESTION 4
You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as
shown in the exhibit.
You need to display rows from the Orders table for the Customers row having the CustomerId value
set to 1 in the following XML format.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
Publicité
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerXd = Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId- 1
FOR XML AUTO
F. SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
G. SELECT Name AS '@Name', Country AS '@Country', OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
H. SELECT Name AS 'Customers/Name', Country AS 'Customers/Country', OrderId, OrderDate,
Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
WHERE Customers.CustomerId= 1
FOR XML PATH ('Customers')
Correct Answer: D
QUESTION 5
You develop a Microsoft SQL Server 2012 server database that supports an application. The
application contains a table that has the following definition:
CREATE TABLE Inventory (
ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInWarehouse int NOT NULL)
You need to create a computed column that returns the sum total of the ItemsInStore and
ItemsInWarehouse values for each row. The new column is expected to be queried heavily, and you
need to be able to index the column. Which Transact-SQL statement should you use?
A. ALTER TABLE Inventory
ADD TotalItems AS ItemslnStore + ItemsInWarehouse
B. ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse PERSISTED
C. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse) PERSISTED
D. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse)
Correct Answer: B
QUESTION 6
You develop a Microsoft SQL Server 2012 database that contains a table named Customers. The
Customers table has the following definition:
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
You need to create an audit record only when either the MobileNumber or HomeNumber column
is updated. Which Transact-SQL query should you use?
A. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_UPDATED (HomeNumber, MobileNumber)
- - Create Audit Records
B. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF EXISTS( SELECT HomeNumber FROM inserted) OR
EXISTS (SELECT MobileNumber FROM inserted)
- - Create Audit Records
C. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_CHANGED (HomeNumber, MobileNumber)
- - Create Audit Records
D. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF UPDATE (HomeNumber) OR UPDATE (MobileNumber)
- - Create Audit Records
Correct Answer: D
QUESTION 7
You develop a Microsoft SQL Server 2012 database that has two tables named SavingAccounts and
LoanAccounts. Both tables have a column named AccountNumber of the nvarchar data type. You
use a third table named Transactions that has columns named TransactionId AccountNumber,
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
Amount, and TransactionDate. You need to ensure that when multiple records are inserted in the
Transactions table, only the records that have a valid AccountNumber in the SavingAccounts or
LoanAccounts are inserted. Which Transact-SQL statement should you use?
A. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted
WHERE AccountNumber IN
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
END
B. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
FOR INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted
WHERE AccountNumber IN
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
END
C. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
D. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
FOR INSERT
AS
BEGIN
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
Correct Answer: A
QUESTION 8
You develop a Microsoft SQL Server 2012 database. You create a view that performs the following
tasks:
Joins 8 tables that contain up to 500,000 records each.
Performs aggregations on 5 fields.
The view is frequently used in several reports. You need to improve the performance of the reports.
What should you do?
A. Convert the view into a table-valued function.
B. Convert the view into a Common Table Expression (CTE).
C. Convert the view into an indexed view.
D. Convert the view into a stored procedure and retrieve the result from the stored procedure
into a temporary table.
Correct Answer: C
QUESTION 9
You are a database developer of a Microsoft SQL Server 2012 database. The database contains a
table named Customers that has the following definition:
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
You need to ensure that the CustomerId column in the Orders table contains only values that exist
in the CustomerId column of the Customer table. Which Transact-SQL statement should you use?
A. ALTER TABLE Orders
ADD CONSTRAINT FX_Orders_CustomerID FOREIGN KEY (CustomerId) REFERENCES Customer
(CustomerId)
B. ALTER TABLE Customer
ADD CONSTRAINT FK_Customer_CustomerID FOREIGN KEY {CustomerID) REFERENCES Orders
(CustomerId)
C. ALTER TABLE Orders
ADD CONSTRAINT CK_Crders_CustomerID
CHECK (CustomerId IN (SELECT CustomerId FROM Customer))
D. ALTER TABLE Customer
Publicité
ADD OrderId INT NOT NULL;
ALTER TABLE Customer
ADD CONSTRAINT FK_Customer_OrderID FOREIGN KEY (CrderlD) REFERENCES Orders
(CrderlD);
E. ALTER TABLE Orders
ADD CONSTRAINT PK Orders CustomerId PRIMARY KEY (CustomerID)
Correct Answer: A
QUESTION 10
You have three tables that contain data for dentists, psychiatrists, and physicians. You create a view
that is used to look up their email addresses and phone numbers. The view has the following
definition:
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
You need to ensure that users can update only the phone numbers and email addresses by using
this view. What should you do?
A. Alter the view. Use the EXPAND VIEWS query hint along with each SELECT statement.
B. Create an INSTEAD OF UPDATE trigger on the view.
C. Drop the view. Re-create the view by using the SCHEMABINDING clause, and then create an
index on the view.
D. Create an AFTER UPDATE trigger on the view.
Correct Answer: B
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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.
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:
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.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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
)
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 13
You have a database that contains the tables shown in the exhibit.
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.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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.
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.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 16
You have a database that contains the tables as shown in the exhibit.
You have the following query:
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.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 17
You have a database that contains the tables shown in the exhibit.
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.
Publicité
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?
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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)
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 19
You have a database that contains the tables as shown in the exhibit.
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:
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
ProductCatalog.CatID,
ProductCatalog.CatName,
SELECT
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
ProductCatalog.ProductID,
QUESTION 20
You have a database that contains the tables shown in the exhibit.
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:
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
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
QUESTION 21
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
You have a database that contains the tables as shown below:
You have a stored procedure named Procedure1. Procedure1 retrieves all order ids after a specific
date. The rows for Procedure1 are not sorted. Procedure1 has a single parameter named
Parameter1. Parameter1 uses the varchar type and is configured to pass the specific date to
Procedure1. A database administrator discovers that OrderDate is not being compared correctly to
Parameter1 after the data type of the column is changed to datetime. You need to update the
SELECT statement to meet the following requirements:
The code must NOT use aliases.
The code must NOT use object delimiters.
The objects called in Procedure1 must be able to be resolved by all users.
OrderDate must be compared to Parameter1 after the data type of Parameter1 is changed to
datetime.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
Which SELECT statement should you use?
To answer, type the correct code in the answer area.
Correct Answer:
SELECT Orders.OrderID
FROM Orders
WHERE Orders.OrderDate>CONVERT(datetime,@Parameter1)
QUESTION 22
You use Microsoft SQL Server 2012 database to develop a shopping cart application. You need to
invoke a table-valued function for each row returned by a query. Which Transact-SQL operator
should you use?
A. CROSS JOIN
B. UNPIVOT
C. PIVOT
D. CROSS APPLY
Correct Answer: D
QUESTION 23
You support a database structure shown in the exhibit.
You need to write a query that displays the following details:
Total sales made by sales people, year, city, and country
Sub totals only at the city level and country level
A grand total of the sales amount
Which Transact-SQL query should you use?
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
A. SELECT SalesPerson.Name, Country, City,
DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total
FROM Sale INNER JOIN SalesPerson
ON Sale.SalesPersonID = SalesPerson.SalesPersonID
GROUP BY GROUPING SETS((SalesPerson.Name, Country, City, DatePart(yyyy, SaleDate)),
(Country, City), (Country), ())
B. SELECT SalesPerson.Name, Country, City,
DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total
FROM Sale INNER JOIN SalesPerson
ON Sale.SalesPersonID = SalesPerson.SalesPersonID
GROUP BY CUBE(SalesPerson.Name, Country, City, DatePart(yyyy, SaleDate))
C. SELECT SalesPerson.Name, Country, City,
DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total
FROM Sale INNER JOIN SalesPerson
ON Sale.SalesPersonID = SalesPerson.SalesPersonID
GROUP BY CUBE(SalesPerson.Name, DatePart(yyyy, SaleDate), City, Country)
D. SELECT SalesPerson.Name, Country, City,
DatePart(yyyy, SaleDate) AS Year, Sum(Amount) AS Total
FROM Sale INNER JOIN SalesPerson
ON Sale.SalesPersonID = SalesPerson.SalesPersonID
GROUP BY ROLLUP(SalesPerson.Name, DatePart(yyyy, SaleDate), City, Country)
Correct Answer: A
QUESTION 24
You are developing a database that will contain price information. You need to store the prices that
include a fixed precision and a scale of six digits. Which data type should you use?
A. Float
B. Money
C. Smallmoney
D. Numeric
Correct Answer: D
QUESTION 25
You administer a Microsoft SQL Server database that supports a banking transaction management
application. You need to retrieve a list of account holders who live in cities that do not have a
branch location. Which Transact-SQL query or queries should you use? (Each correct answer
presents a complete solution. Choose all that apply.)
A. SELECT AccountHolderID
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
FROM AccountHolder
WHERE CityID NOT IN (SELECT CityID FROM BranchMaster)
B. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ALL (SELECT CityID FROM BranchMaster)
Publicité
C. SELECT AccountHolderlD
FROM AccountHolder
WHERE CityID <> SOME (SELECT CityID FROM BranchMaster)
D. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ANY (SELECT CityID FROM BranchMaster)
Correct Answer: AB
QUESTION 26
You administer a Microsoft SQL Server 2012 database. The database contains a table named
Employee. Part of the Employee table is shown in the exhibit.
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
Confidential information about the employees is stored in a separate table named EmployeeData.
One record exists within EmployeeData for each record in the Employee table. You need to assign
the appropriate constraints and table properties to ensure data integrity and visibility. On which
column in the Employee table should you a create a unique constraint?
A. DateHired
B. DepartmentID
C. EmployeelD
D. EmployeeNum
E. FirstName
F.
JobTitle
G. LastName
H. MiddleName
I. ReportsToID
Correct Answer: D
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
QUESTION 27
You administer a Microsoft SQL Server 2012 database. The database contains a table named
Employee. Part of the Employee table is shown in the exhibit.
Confidential information about the employees is stored in a separate table named EmployeeData.
One record exists within EmployeeData for each record in the Employee table. You need to assign
the appropriate constraints and table properties to ensure data integrity and visibility. On which
column in the Employee table should you use an identity specification to include a seed of 1,000
and an increment of 1?
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
A. DateHired
B. DepartmentID
C. EmployeeID
D. EmployeeNum
E. FirstName
F.
JobTitle
G. LastName
H. MiddleName
I. ReportsToID
Correct Answer: C
QUESTION 28
You administer a Microsoft SQL Server 2012 database that includes a table named Products. The
Products table has columns named Productld, ProductName, and CreatedDateTime. The table
contains a unique constraint on the combination of ProductName and CreatedDateTime. You need
to modify the Products table to meet the following requirements:
Remove all duplicates of the Products table based on the ProductName column.
Retain only the newest Products row.
Which Transact-SQL query should you use?
A. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName
AND p.CreatedDateTime > cte.CreatedDateTime
B. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
cte.ProductName = p.ProductName
AND cte.CreatedDateTime > p.CreatedDateTime
C. WITH CTEDupRecords
AS
(
SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName
D. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName
Correct Answer: B
QUESTION 29
You develop three Microsoft SQL Server 2012 databases named Database1, Database2, and
Database3. You have permissions on both Database1 and Database2. You plan to write and deploy
a stored procedure named dbo.usp_InsertEvent in Database3. dbo.usp_InsertEvent must execute
other stored procedures in the other databases. You need to ensure that callers that do not have
permissions on Database1 or Database2 can execute the stored procedure. Which Transact-SQL
statement should you use?
A. USE Database2
B. EXECUTE AS OWNER
C. USE Database1
Download the complete collection of Exam's Real Q&As www.ensurepass.com
Ensurepass.com Easy Test! Easy Pass!
D. EXECUTE AS CALLER
Correct Answer: B
QUESTION 30
You develop a Microsoft SQL Server 2012 database that contains tables named Customers and
Orders. The tables are related by a column named CustomerId . You need to create a query that
meets the following requirements:
Returns the CustomerName for all customers and the OrderDate for any orders that they have
placed.
Results must not include customers who have not placed any orders.
Which Transact-SQL query should you use?
A. SELECT CustomerName, OrderDate
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CuscomerlD = Orders.CustomerId
B. SELECT CustomerName, OrderDate
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerId
C. SELECT CustomerName, OrderDate
FROM Customers
CROSS JOIN Orders
ON Customers.CustomerId = Orders.CustomerId
D. SELECT CustomerName, OrderDate
FROM Customers
JOIN Orders
ON Customers.CustomerId = Orders.CustomerId
Correct Answer: D
QUESTION 31
You develop a Microsoft SQL Server 2012 database. You need to create a batch process that meets
the following requirements:
Status information must be logged to a status table.
If the status table does not exist at the beginning of the batch, it must be created.
Wh...