Exam 70 461 Querying Microsoft SQL Server 2012
Exam 70 461 Querying Microsoft SQL Server 2012
McirosoQ
ft uesotins&Answers Home
Search
J U S T A N O T H E R A L L I N O N E T E S T Membership
K I N G S Subscribe
I T E S
CheckPoint Cisco CIW CompTIA CWNP EC-Council ISC2 Juniper Linux Microsoft Oracle Sun VMWare EMC Exin Isilon PMI HP IBM ISACA
E X A M I N F O R M AWhich
T I O N
Transact-SQL query should you use?
Posted by seenagape on May 21, 2013 No comments
RSS feed for this section
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. Tables are defined as show n in the
This category contains
exhibit. (Refer to the Exhibit.)
95 posts
You need to display row s from the Orders table for the Customers row having the CustomerId value set to 1 in
the follow ing 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”
/>
W hich 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
W HERE Customers.CustomerId = 1
FOR XML RAW , ELEMENTS
C.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML AUTO
D.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId – Customers.CustomerId
W HERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E.
SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
W HERE Customers.CustomerId- 1
FOR XML AUTO
F.
SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
W HERE 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
W HERE 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
W HERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/bb510464.aspx
Which Transact-SQL query should you use?
Posted by seenagape on May 21, 2013 No comments
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. Tables are defined as show n in the
exhibit. (Refer to the Exhibit.)
You need to display row s from the Orders table for the Customers row having the CustomerIdvalue set to1 in
the follow ing XML format.
A.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML RAW
B.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE 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
W HERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E.
SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
W HERE Customers.CustomerId= 1
FOR XML AUTO
F.
SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
W HERE 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
W HERE 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
W HERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms188273.aspx
You need to display row s from the Orders table for the Customers row having the CustomerId value set to 1 in
the follow ing 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>
W hich Transact-SQL query should you use?
A.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML RAW
B.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML RAW , ELEMENTS
C.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML AUTO
D.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId – Customers.CustomerId
W HERE 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
W HERE 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
W HERE 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
W HERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. Tables are defined as show n in the
exhibit. (Refer to the Exhibit.)
You need to display row s from the Orders table for the Customers row having the CustomerId value set to 1 in
the follow ing XML format.
A.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML RAW
B.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers.CustomerId = 1
FOR XML RAW , ELEMENTS
C.
SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
W HERE 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
W HERE Customers.CustomerId- 1
FOR XML AUTO
F.
SELECT Name, Country, Orderld, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId
W HERE 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
W HERE 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
W HERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
Which Transact-SQL statement should you use?
Posted by seenagape on May 21, 2013 1 comment
You develop a Microsoft SQL Server 2012 server database that supports an application. The application
contains a table that has the follow ing definition:
CREATE TABLE Inventory (
ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInW arehouse int NOT NULL)
You need to create a computed column that returns the sum total of the ItemsInStore and ItemsInW arehouse
values for each row . The new column is expected to be queried heavily, and you need to be able to index the
column. W hich Transact-SQL statement should you use?
A.
ALTER TABLE Inventory
ADD TotalItems AS ItemslnStore + ItemsInW arehouse
B.
ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse PERSISTED
C.
ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInW arehouse) PERSISTED
D.
ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInW arehouse)
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms174979.aspx
You develop a Microsoft SQL Server 2012 database that contains a table named Customers. The Customers
table has the follow ing definition:
You need to create an audit record only w hen eitherthe MobileNumber or HomeNumber column is updated.
W hich 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
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/bb510663.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms186329.aspx
You develop a Microsoft SQL Server 2012 database that has tw o 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, Amount, and
TransactionDate. You need to ensure that w hen multiple records are inserted in the Transactions table,only the
records that have a valid AccountNumber in the SavingAccounts or LoanAccounts are inserted. W hich
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
W HERE 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
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
Explanation:
Verified answer as correct.
You develop a Microsoft SQL Server 2012 database. You create a view that performs the follow ing 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. Youneed to improve the performance of the reports.
W hat 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.
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms191432.aspx
You are a database developer of a Microsoft SQL Server 2012 database. The database contains a table named
Customers that has the follow ing definition:
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. W hich 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
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)
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms189049.aspx
You need to ensure that users can update only the phone numbers and email addresses by using
this view
Posted by seenagape on May 21, 2013 No comments
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 follow ing definition:
You need to ensure that users can update only the phone numbers and email addresses by using this view .
W hat should you do?
A.
Alter the view . Use the EXPAND VIEW S query hint along w ith 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 .
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms187956.aspx
You need to ensure that users are able to modify data by using the view
Posted by seenagape on May 21, 2013 No comments
You develop a Microsoft SQL Server 2012 database. You create a view from the Orders and OrderDetails
tables by using the follow ing definition.
You need to ensure that users are able to modify data by using the view . W hat should you do?
A.
Create an AFTER trigger on the view .
B.
Modify the view to use the W ITH VIEW _METADATA clause.
C.
Create an INSTEAD OF trigger on the view.
D.
Modify the view to an indexed view .
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms187956.aspx
You have a view that w as created by using the follow ing code:
You need to create an inline table-valued function named Sales.fn_OrdersByTerritory, w hich must meet the
follow ing 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 .
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)
RETURNS TABLE
AS
RETURN
(
SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue
FROM Sales.OrdersByTerritory
WHERE SalesTerritoryID = @T
)
You have a database that contains the tables show n in the exhibit. (Refer to 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 follow ing requirements:
W rite 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. W hich code segment
should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
CREATE TABLE Sales.OrderDetails (
ListPrice money not null,
Quantity int not null,
LineItemTotal as (ListPrice * Quantity) PERSISTED)
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms174979.aspx
Reference: http://technet.microsoft.com/en-us/library/ms188300.aspx
You have a database that contains the tables show n in the exhibit. (Refer to the Exhibit.)
You need to create a view named uv_CustomerFullNameto meet the follow ing 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.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
CREATE VIEW Sales.uv_CustomerFullName
WITH SCHEMABINDING
AS
SELECT FirstName, LastName
FROM Sales.Customers
Reference: http://msdn.microsoft.com/en-us/library/ms187956.aspx
You have a database that contains the tables show n in the exhibit. (Refer to the Exhibit.)
You need to create a query that calculates the total sales of each OrderId from the Sales.Details table. The
solution must meet the follow ing 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.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
SELECT OrderID, SUM(ExtendedAmount) AS TotalSales
FROM Sales.Details
GROUP BY OrderID
ORDER BY OrderID
You have a database that contains the tables as show n in the exhibit. (Refer to the Exhibit.)
A.
Explanation:
SELECT SalesTerritoryID,
ProductID,
AVG(UnitPrice),
MAX(OrderQty),
MAX(DiscountAmount)
FROM Sales.Details
GROUP BY SalesTerritoryID , ProductID
ORDER BY SalesTerritoryID DESC, ProductID DESC
You have a database that contains the tables show n in the exhibit. (Refer to the Exhibit).
You need to create a query for a report. The query must meet the follow ing 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 w ho placed theorder.
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.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
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
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 XML1is validated by using Sales.InvoiceSchema.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
DECLARE @XML1 XML(Sales.InvoiceSchema)
Reference: http://msdn.microsoft.com/en-us/library/ms176009.aspx
You have a database that contains the tables as show n in the exhibit. (Refer to the Exhibit.)
You need to create a query that returns a list of products from Sales.ProductCatalog. The solution must meet
the follow ing requirements:
UnitPrice must be returned in descending order.
The query must use tw o-part names to reference the table.
The query must use the RANK function to calculate the results.
The query must return the ranking of row s in a column named PriceRank.
The list must display the columns in the order thatthey are defined in the table.
PriceRank must appear last.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
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
You have a database that contains the tables show n in the exhibit. (Refer to 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 thefollow ing 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 row s specified by the @Count parameter.
The solution must NOT use BEGIN and END statements.
W hich code segment should you use?
To answ er, type the correct code in the answ er area.
A.
Explanation:
CREATE PROCEDURE usp_Customers @Count int
AS
SELECT TOP(@Count) Customers.LastName
FROM Customers
ORDER BY Customers.LastName
A.
Explanation:
SELECT Orders.OrderID
FROM Orders
WHERE Orders.OrderDate>CONVERT(datetime,@Parameter1)
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. W hich Transact-SQL operator should you use?
A.
CROSS JOIN
B.
UNPIVOT
C.
PIVOT
D.
CROSS APPLY
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms175156.aspx
You support a database structure show n in the exhibit. (Refer to the Exhibit.)
You need to w rite a query that displays the follow ing 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
W hich Transact-SQL query should you use?
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)
Explanation:
Verified answer as correct.
Reference: http://www.grapefruitmoon.net/diving-into-t-sql-grouping-sets/
Reference: http://msdn.microsoft.com/en-us/library/ms177673.aspx
You are developing a database that w ill contain price information. You need to store the prices that include a
fixed precision and a scale of six digits. W hich data type should you use?
A.
Float
B.
Money
C.
Smallmoney
D.
Numeric
Explanation:
Numeric is the only one in the list that can give afixed precision and scale.
Reference: http://msdn.microsoft.com/en-us/library/ms179882.aspx
You administer a Microsoft SQL Server database thatsupports a banking transaction management application.
You need to retrieve a list of account holders w ho live in cities that do not have a branch location. W hich
Transact-SQL query or queries should you use? (Eachcorrect answ er presents a complete solution. Choose all
that apply.)
A.
SELECT AccountHolderID
FROM AccountHolder
WHERE CityID NOT IN (SELECT CityID FROM BranchMaster)
B.
SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ALL (SELECT CityID FROM BranchMaster)
C.
SELECT AccountHolderlD
FROM AccountHolder
W HERE CityID <> SOME (SELECT CityID FROM BranchMaster)
D.
SELECT AccountHolderID
FROM AccountHolder
W HERE CityID <> ANY (SELECT CityID FROM BranchMaster)
Explanation:
Verified the answers as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms188047.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms177682.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms173545.aspx
which column in the Employee table should you a create a unique constraint?
Posted by seenagape on May 21, 2013 No comments
You administer a Microsoft SQL Server 2012 database. The database contains a table named Employee. Part
of the Employee table is show n in the exhibit. (Refer to the Exhibit.)
Confidential information about the employees is stored in a separate table named EmployeeData. One record
exists w ithin 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 w hich 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
Explanation:
Verified answer as correct.
which column in the Employee table should you use an identity specification to includea seed of
1,000 and an increment of 1?
Posted by seenagape on May 21, 2013 No comments
You administer a Microsoft SQL Server 2012 database. The database contains a table named Employee. Part
of the Employee table is show n in the exhibit. (Refer to the Exhibit.)
Confidential information about the employees is stored in a separate table named EmployeeData. One record
exists w ithin 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 w hich column in the Employee table
should you use an identity specification to includea seed of 1,000 and an increment of 1?
A.
DateHired
B.
DepartmentID
C.
EmployeeID
D.
EmployeeNum
E.
FirstName
F.
JobTitle
G.
LastName
H.
MiddleName
I.
ReportsToID
Explanation:
Verified answer as correct.
You administer a Microsoft SQL Server 2012 databasethat includes a table named Products. The Products
table has columns named Productld, ProductName, andCreatedDateTime. The table contains a unique
constraint on the combination of ProductName and CreatedDateTime. You need to modify the Products table to
meet the follow ing requirements:
Remove all duplicates of the Products table based on the ProductName column.
Retain only the new est Products row .
W hich Transact-SQL query should you use?
A.
W ITH 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
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
cte.ProductName = p.ProductName
AND cte.CreatedDateTime > p.CreatedDateTime
C.
W ITH 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.
W ITH 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
Explanation:
Verified answer as correct.
You develop three Microsoft SQL Server 2012 databases named Database1, Database2, and Database3. You
have permissions on both Database1 and Database2. You plan to w rite 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. W hich Transact-SQL statement should you use?
A.
USE Database2
B.
EXECUTE AS OWNER
C.
USE Database1
D.
EXECUTE AS CALLER
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms188354.aspx
Reference: http://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure-calling-stored-
procedure-on-linked-server/
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 follow ing
requirements:
Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
Results must not include customers w ho have not placed any orders.
W hich 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
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms177634.aspx
A.
Scalar user-defined function
B.
Inline user-defined function
C.
Table-valued user-defined function
D.
Stored procedure
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms186755.aspx
You administer a database that includes a table named Customers that contains more than 750 row s. You
create a new column named PartitionNumber of the int type in the table. You need to assign a PartitionNumber
for each record in the Customers table. You also need to ensure that the PartitionNumber satisfies thefollow ing
conditions:
Alw ays starts w ith 1.
Starts again from 1 after it reaches 100.
W hich Transact-SQL statement should you use?
A.
CREATE SEQUENCE CustomerSequence AS int
START W ITH 0
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence
B.
CREATE SEQUENCE CustomerSequence AS int
START WITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
CYCLE
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence
C.
CREATE SEQUENCE CustomerSequence AS int
START W ITH 1
INCREMENT BY 1
MINVALUE 1
MAXVALUE 100
UPDATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence + 1
DROP SEQUENCE CustomerSequence
D.
CREATE SEQUENCE CustomerSequence AS int
START W ITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 100
CYCLE
UPTATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ff878091.aspx
You use a Microsoft SQL Server 2012 database that contains a table named BlogEntry that has the follow ing
columns:
Id is the Primary Key.
You need to append the “This is in a draft stage” string to the Summary column of the recent 10 entries based
on the values in EntryDateTime. W hich Transact-SQL statement should you use?
A.
UPDATE TOP(10) BlogEntry
SET Summary.W RITE(N’ This is in a draft stage’, NULL, 0)
B.
UPDATE BlogEntry
SET Summary = CAST(N’ This is in a draft stage’ as nvarchar(max))
W HERE Id IN(SELECT TOP(10) Id FROM BlogEntry ORDER BY EntryDateTime DESC)
C.
UPDATE BlogEntry
SET Summary.WRITE(N’ This is in a draft stage’, NULL, 0) FROM (
SELECT TOP(10) Id FROM BlogEntry ORDER BY EntryDateTime DESC) AS s
WHERE BlogEntry.Id = s.ID
D.
UPDATE BlogEntry
SET Summary.W RITE(N’ This is in a draft stage’, 0, 0)
W HERE Id IN(SELECT TOP(10) Id FROM BlogEntry ORDER BY EntryDateTime DESC)
Explanation:
Verified answer as correct.
You use Microsoft SQL Server 2012 to develop a database application. You create a stored procedure named
DeleteJobCandidate. You need to ensure that if DeleteJobCandidate encounters an error, the execution of the
stored procedure reports the error number. W hich Transact-SQL statement should you use?
A.
DECLARE @ErrorVar INT;
DECLARE @RowCountVar INT;
EXEC DeleteJobCandidate
SELECT @ErrorVar = @@ERROR, @RowCountVar = @@ROWCOUNT;
IF (@ErrorVar <> 0)
PRINT N’Error = ‘ + CAST(@@ErrorVar AS NVARCHAR(8)) +
N’, Rows Deleted = ‘ + CAST(@@RowCountVar AS NVARCHAR(8));
GO
B.
DECLARE @ErrorVar INT;
DECLARE @Row CountVar INT;
EXEC DeleteJobCandidate
SELECT @ErrorVar = ERROR_STATE(), @Row CountVar = @@ROW COUNT;
IF (@ErrorVar <> 0)
PRINT N’Error = ‘ + CAST(ERRORSTATE() AS NVARCHAR(8)) +
N’, Row s Deleted = ‘ + CAST(@@Row CountVar AS NVARCHAR(8));
GO
C.
EXEC DeleteJobCandidate
IF (ERROR_STATE() != 0)
PRINT N’Error = ‘ + CAST(@@ERROR AS NVARCHAR(8)) +
N’, Row s Deleted = ‘ + CAST(@@ROW COUNT AS NVARCHAR(8));
GO
D.
EXEC DeleteJobCandidate
PRINT N’Error = ‘ + CAST(@@ERROR AS NVARCHAR(8)) +
N’, Row s Deleted = ‘ + CAST(@@ROW COUNT AS NVARCHAR(8));
GO
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms190193.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms188790.aspx
The procedure can be called w ithin other transactions. You need to ensure that w hen the DELETE statement
from the HumanResourcesJobCandidate table succeeds,the modification is retained even if the insert into the
Audit.Log table fails. W hich code segment should you add to line 14?
A.
IF @@TRANCOUNT = 0
B.
IF (XACT_STATE ( ) ) = 0
C.
IF (XACT_STATE ( ) ) = 1
D.
IF @@TRANCOUNT = l
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms189797.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms187967.aspx
A table named Profits stores the total profit made each year w ithin a territory. The Profits table hascolumns
named Territory, Year, and Profit. You need to create a report that displays the profits made by each territory
for each year and its preceding year. W hich Transact-SQL query should you use?
A.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER(PARTITION BY Year ORDER BYTerritory) AS NextProfit
FROM Profits
B.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER(PARTITION BY Territory ORDER BY Year) AS NextProfit
FROM Profits
C.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER(PARTITION BY Territory ORDER BY Year) AS NextProfit
FROM Profits
D.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER(PARTITION BY Year ORDER BY Territory) AS NextProfit
FROM Profits
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/hh231256.aspx
Reference: http://msdn.microsoft.com/en-us/library/hh213125.aspx
You use Microsoft SQL Server 2012 to develop a database application. Your application sends data to an
NVARCHAR(MAX) variable named @var. You need to w rite a Transact-SQL statement that w ill find out the
success of a cast to a decimal (36,9). W hich code segment should you use?select
A.
BEGIN TRY
SELECT convert(decimal(36,9), @var) AS Value, ‘True’ AS BadCast
END TRY
BEGIN CATCH
SELECT convert(decimal(36,9), @var) AS Value, ‘False’ AS BadCast
END CATCH
B.
TRY(
SELECT convert(decimal(36,9), @var)
SELECT ‘True’ AS BadCast
)
CATCH(
SELECT ‘False’ AS BadCast
)
C.
SELECT
CASE
W HEN convert(decimal(36,9), @var) IS NULL
THEN ‘True’
ELSE ‘False’
END
AS BadCast
D.
SELECT
IIF(TRY_PARSE(@var AS decimal(36,9)) IS NULL, ‘True’, ‘False’)
AS BadCast
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/hh213126.aspx
Which Transact-SQL statement should you include at the beginning of the stored procedure?
Posted by seenagape on May 21, 2013 No comments
You are w riting a set of queries against a FILESTREAM-enabled database. You create a stored procedure that
w ill update multiple tables w ithin a transaction. You need to ensure that if the stored procedure raises a run-time
error, the entire transaction is terminated and rolled back. W hich Transact-SQL statement should you
include at the beginning of the stored procedure?
A.
SET TRANSACTION ISOLATION LEVEL SERIALIZABLE
B.
SET XACT_ABORT OFF
C.
SET TRANSACTION ISOLATION LEVEL SNAPSHOT
D.
SET IMPLICIT_TRANSACTIONS ON
E.
SET XACT_ABORT ON
F.
SET IMPLICIT TRANSACTIONS OFF
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms188792.aspx
You have 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 follow ing
requirements:
Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
Results must include customers w ho have not placed any orders.
W hich Transact-SQL query should you use?
A.
SELECT CustomerName, OrderDate
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
B.
SELECT CustomerName, CrderDate
FROM Customers
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
LEFT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerID
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms177634.aspx
Which Transact-SQL statement should you include at the beginning of the stored procedure?
Posted by seenagape on May 21, 2013 No comments
You create a stored procedure that w ill update multiple tables w ithin a transaction. You need to ensure that if
the stored procedure raises a run-time error, the entire transaction is terminated and rolled back. W hich
Transact-SQL statement should you include at the beginning of the stored procedure?
A.
SET XACT_ABORT ON
B.
SET ARITHABORT ON
C.
TRY
D.
BEGIN
E.
SET ARITHABORT OFF
F.
SET XACT_ABORT OFF
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms190306.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms188792.aspx
Your database contains tw o tables named DomesticSalesOrders and InternationalSalesOrders. Both tables
contain more than 100 million row s. Each table has a Primary Key column named SalesOrderId. The data in
the tw o tables is distinct from one another. Business users w ant a report that includes aggregate information
about the total number of global sales and total sales amounts. You need to ensure that your query executes in
the minimum possible time. W hich query should you use?
A.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM (
SELECT SalesOrderId, SalesAmount
FROM DomesticSalesOrders
UNION ALL
SELECT SalesOrderId, SalesAmount
FROM InternationalSalesOrders
) AS p
B.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM (
SELECT SalesOrderId, SalesAmount
FROM DomesticSalesOrders
UNION
SELECT SalesOrderId, SalesAmount
FROM InternationalSalesOrders
) AS p
C.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM DomesticSalesOrders
UNION
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM InternationalSalesOrders
D.
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM DomesticSalesOrders
UNION ALL
SELECT COUNT(*) AS NumberOfSales, SUM(SalesAmount) AS TotalSalesAmount
FROM InternationalSalesOrders
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms180026.aspx
Reference: http://blog.sqlauthority.com/2009/03/11/sql-server-difference-between-union-vs-union-all-optimal-
performance-comparison/
You are a database developer at an independent softw are vendor. You create stored procedures that contain
proprietary code. You need to protect the code frombeing view ed by your customers. W hich stored procedure
option should you use?
A.
ENCRYPTBYKEY
B.
ENCRYPTION
C.
ENCRYPTBYPASSPHRASE
D.
ENCRYPTBYCERT
Explanation:
Verified answer as correct.
Reference: http://technet.microsoft.com/en-us/library/bb510663.aspx
Reference: http://technet.microsoft.com/en-us/library/ms174361.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms187926.aspx
Reference: http://technet.microsoft.com/en-us/library/ms190357.aspx
Reference: http://technet.microsoft.com/en-us/library/ms188061.aspx
You use a Microsoft SQL Server 2012 database. You w ant to create a table to store Microsoft W ord
documents. You need to ensure that the documents must only be accessible via Transact-SQL queries. W hich
Transact-SQL statement should you use?
A.
CREATE TABLE DocumentStore
(
[Id] INT NOT NULL PRIMARY KEY,
[Document] VARBINARY(MAX) NULL
)
GO
B.
CREATE TABLE DocumentStore
(
[Id] hierarchyid,
[Document] NVARCHAR NOT NULL
)
GO
C.
CREATE TABLE DocumentStore AS FileTable
D.
CREATE TABLE DocumentStore
(
[Id] [uniqueidentifier] ROW GUIDCOL NOT NULL UNIQUE,
[Document] VARBINARY(MAX) FILESTREAM NULL
)
GO
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/gg471497.aspx
Reference: http://msdn.microsoft.com/en-us/library/ff929144.aspx
Exam B
You develop a Microsoft SQL Server 2012 database that contains a heap named OrdersHistoncal.
You w rite the follow ing Transact-SQL query:
INSERT INTO OrdersHistorical
SELECT * FROM CompletedOrders
You need to optimize transaction logging and locking for the statement. W hich table hint should you use?
A.
HOLDLOCK
B.
ROW LOCK
C.
XLOCK
D.
UPDLOCK
E.
TABLOCK
Explanation:
Reference: http://technet.microsoft.com/en-us/library/ms189857.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms187373.aspx
You use a Microsoft SQL Server 2012 database that contains tw o tables named SalesOrderHeader and
SalesOrderDetail. The indexes on the tables are as show n in the exhibit. (Refer to the Exhibit.)
You discover that the performance of the query is slow . Analysis of the query plan show s table scans w here the
estimated row s do not match the actual row s for SalesOrderHeader by using an unexpected index on
SalesOrderDetail. You need to improve the performance of the query. W hat should you do?
A.
Use a FORCESCAN hint in the query.
B.
Add a clustered index on SalesOrderId in SalesOrderHeader.
C.
Use a FORCESEEK hint in the query.
D.
Update statistics on SalesOrderId on both tables.
Explanation:
References: http://msdn.microsoft.com/en-us/library/ms187348.aspx
Which Transact-SQL query should you use?
Posted by seenagape on May 21, 2013 3 comments
Your database contains a table named Purchases. Thetable includes a DATETIME column named
PurchaseTime that stores the date and time each purchase is made. There is a non-clustered index on the
PurchaseTime column. The business team w ants a report that displays the total number of purchases madeon
the current day. You need to w rite a query that w ill return the correct results in the most efficient manner. W hich
Transact-SQL query should you use?
A.
SELECT COUNT(*)
FROM Purchases
W HERE PurchaseTime = CONVERT(DATE, GETDATE())
B.
SELECT COUNT(*)
FROM Purchases
W HERE PurchaseTime = GETDATE()
C.
SELECT COUNT(*)
FROM Purchases
W HERE CONVERT(VARCHAR, PurchaseTime, 112) = CONVERT(VARCHAR, GETDATE(), 112)
D.
SELECT COUNT(*)
FROM Purchases
WHERE PurchaseTime >= CONVERT(DATE, GETDATE())
AND PurchaseTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))
Explanation:
Two answers will return the correct results (the “WHERE CONVERT…” and “WHERE … AND … ” answers).
The correct answer for Microsoft would be the answer that is most “efficient”. Anybody have a clue as to which
is most efficient? In the execution plan, the one that I’ve selected as the correct answer is the query with the
shortest duration. Also, the query answer with “WHERE CONVERT…” threw warnings in the execution plan…
something about affecting CardinalityEstimate and SeekPlan.
I also found this article, which leads me to believe that I have the correct answer:
http://technet.microsoft.com/en-us/library/ms181034.aspx
You need to design tables and other database objects.You need to store media files in several
tables
Posted by seenagape on May 21, 2013 No comments
You develop a database for a travel application. You need to design tables and other database objects.You
need to store media files in several tables. Each media file is less than 1 MB in size. The media files w ill require
fast access and w ill be retrieved frequently. W hat should you do?
A.
Use the CAST function.
B.
Use the DATE data type.
C.
Use the FORMAT function.
D.
Use an appropriate collation.
E.
Use a user-defined table type.
F.
Use the VARBINARY data type.
G.
Use the DATETIME data type.
H.
Use the DATETIME2 data type.
I.
Use the DATETIMEOFFSET data type.
J.
Use the TODATETIMEOFFSET function.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms188362.aspx
You develop a database for a travel application. You need to design tables and other database objects.You
create a view that displays the dates and times of the airline schedules on a report. You need to display dates
and times in several international formats. W hat should you do?
A.
Use the CAST function.
B.
Use the DATE data type.
C.
Use the FORMAT function.
D.
Use an appropriate collation.
E.
Use a user-defined table type.
F.
Use the VARBINARY data type.
G.
Use the DATETIME data type.
H.
Use the DATETIME2 data type.
I.
Use the DATETIMEOFFSET data type.
J.
Use the TODATETIMEOFFSET function.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/hh213505.aspx
You are a database developer of a Microsoft SQL Server 2012 database. You are designing a table that w ill
store Customer data from different sources. The table w ill include a column that contains the CustomerID from
the source system and a column that contains the SourceID. A sample of this data is as show n in the follow ing
table.
You need to ensure that the table has no duplicate CustomerID w ithin a SourceID. You also need to ensure that
the data in the table is in the order of SourceID and then CustomerID. W hich Transact- SQL statement should
you use?
A.
CREATE TABLE Customer
(SourceID int NOT NULL IDENTITY,
CustomerID int NOT NULL IDENTITY,
CustomerName varchar(255) NOT NULL);
B.
CREATE TABLE Customer
(SourceID int NOT NULL,
CustomerID int NOT NULL PRIMARY KEY CLUSTERED,
CustomerName varchar(255) NOT NULL);
C.
CREATE TABLE Customer
(SourceID int NOT NULL PRIMARY KEY CLUSTERED,
CustomerID int NOT NULL UNIQUE,
CustomerName varchar(255) NOT NULL);
D.
CREATE TABLE Customer
(SourceID int NOT NULL,
CustomerID int NOT NULL,
CustomerName varchar(255) NOT NULL,
CONSTRAINT PK_Customer PRIMARY KEY CLUSTERED
(SourceID, CustomerID));
Explanation:
Verified the answer as correct.
You need to ensure that users can update only the phone numbers by using this view
Posted by seenagape on May 21, 2013 No comments
You have three tables that contain data for vendors, customers, and agents. You create a view that is used to
look up telephone numbers for these companies. The view has the follow ing definition:
You need to ensure that users can update only the phone numbers by using this view . W hat should you do?
A.
Alter the view . Use the EXPAND VIEW S query hint along w ith each SELECT statement.
B.
Drop the view . Re-create the view by using the SCHEMABINDING clause, and then create an index on the
view .
C.
Create an AFTER UPDATE trigger on the view .
D.
Create an INSTEAD OF UPDATE trigger on the view.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms187956.aspx
You develop a Microsoft SQL Server 2012 database that contains tables named Employee and Person. The
tables have the follow ing definitions:
You create a view named Vw Employee as show n in the follow ing Transact-SQL statement.
Users are able to use single INSERT statements or INSERT…SELECT statements into this view . You need to
ensure that users are able to use a single statement to insert records into both Employee and Person tables by
using the Vw Employee view . W hich Transact-SQL statement should you use?
A.
CREATE TRIGGER TrgVw Employee
ON Vw Employee
FOR INSERT
AS
BEGIN
INSERT INTO Person(Id, FirstName, LastName)
SELECT Id, FirstName, LastName, FROM inserted
INSERT INTO Employee(PersonId, EmployeeNumber)
SELECT Id, EmployeeNumber FROM inserted
END
B.
CREATE TRIGGER TrgVwEmployee
ON VwEmployee
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Person(Id, FirstName, LastName)
SELECT Id, FirstName, LastName, FROM inserted
INSERT INTO Employee(PersonId, EmployeeNumber)
SELECT Id, EmployeeNumber FROM inserted
END
C.
CREATE TRIGGER TrgVw Employee
ON Vw Employee
INSTEAD OF INSERT
AS
BEGIN
DECLARE @ID INT, @FirstName NVARCHAR(25), @LastNameNVARCHAR(25), @PersonID
INT, @EmployeeNumber NVARCHAR(15)
SELECT @ID = ID, @FirstName = FirstName, @LastName = LastName, @EmployeeNumber
= EmployeeNumber
FROM inserted
INSERT INTO Person(Id, FirstName, LastName)
VALUES(@ID, @FirstName, @LastName)
INSERT INTO Employee(PersonID, EmployeeNumber)
VALUES(@PersonID, @EmployeeNumber
End
D.
CREATE TRIGGER TrgVw Employee
ON Vw Employee
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Person(Id, FirstName, LastName)
SELECT Id, FirstName, LastName FROM Vw Employee
INSERT INTO Employee(PersonID, EmployeeNumber)
SELECT Id, EmployeeNumber FROM Vw Employee
End
Explanation:
Verified answer as correct.
You develop a Microsoft SQL Server 2012 database that contains a table named Products. The Products table
has the follow ing definition:
You need to create an audit record only w hen eitherthe RetailPrice or W holeSalePrice column is updated.
W hich Transact-SQL query should you use?
A.
CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF CCLUMNS_CHANGED(RetailPrice, W holesalePrice)
- – Create Audit Records
B.
CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF EXISTS(SELECT RetailPrice from inserted) OR
EXISTS (SELECT W holeSalePnce FROM inserted)
- – Create Audit Records
C.
CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF COLUMNS_UPDATED(RetailPrice, W holesalePrice)
- – Create Audit Records
D.
CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
IF UPDATE(RetailPrice) OR UPDATE(WholeSalePrice)
- – Create Audit Records
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/bb510663.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms186329.aspx
You develop a Microsoft SQL Server 2012 server database that supports an application. The application
contains a table that has the follow ing definition:
CREATE TABLE Inventory
(ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInW arehouse int NOT NULL)
You need to create a computed column that returns the sum total of the ItemsInStore and ItemsInW arehouse
values for each row . W hich Transact-SQL statement should you use?
A.
ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse
B.
ALTER TABLE Inventory
ADD ItemsInStore – ItemsInW arehouse = TotalItems
C.
ALTER TABLE Inventory
ADD TotalItems = ItemsInStore + ItemsInW arehouse
D.
ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemslnW arehouse);
Explanation:
Verified answer as correct.
Reference: http://technet.microsoft.com/en-us/library/ms190273.aspx
You need to improve the performance of the view by persisting data to disk
Posted by seenagape on May 21, 2013 No comments
You develop a Microsoft SQL Server 2012 database. You create a view from the Orders and OrderDetails
tables by using the follow ing definition.
You need to improve the performance of the view by persisting data to disk. W hat should you do?
A.
Create an INSTEAD OF trigger on the view .
B.
Create an AFTER trigger on the view .
C.
Modify the view to use the W ITH VIEW _METADATA clause.
D.
Create a clustered index on the view.
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms188783.aspx
Your database contains tables named Products and ProductsPriceLog. The Products table contains columns
named ProductCode and Price. The ProductsPriceLog table contains columns named ProductCode, OldPrice,
and New Price. The ProductsPriceLog table stores theprevious price in the OldPrice column and the new price
in the New Price column. You need to increase the values in the Price column of all products in the Products
table by 5 percent. You also need to log the changes to the ProductsPriceLog table. W hich Transact-SQLquery
should you use?
A.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, deleted.Price, inserted.Price
INTO ProductsPriceLog(ProductCode, OldPrice, NewPrice)
B.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, inserted.Price, deleted.Price
INTO ProductsPriceLog(ProductCode, OldPrice, New Price)
C.
UPDATE Products SET Price = Price * 1.05
OUTPUT inserted.ProductCode, deleted.Price, inserted.Price *
INTO ProductsPriceLog(ProductCode, OldPrice, New Price)
D.
UPDATE Products SET Price = Price * 1.05
INSERT INTO ProductsPriceLog (ProductCode, CldPnce,New Price;
SELECT ProductCode, Price, Price * 1.05 FROM Products
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/ms177564.aspx
A table named Profits stores the total profit made each year w ithin a territory. The Profits table hascolumns
named Territory, Year, and Profit. You need to create a report that displays the profits made by each territory
for each year and its previous year. W hich Transact-SQL query should you use?
A.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) AS PrevProfit
FROM Profits
B.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) AS PrevProfit
FROM Profits
C.
SELECT Territory, Year, Profit,
LAG(Profit, 1, 0) OVER (PARTITION BY Territory ORDER BY Year) AS PrevProfit
FROM Profits
D.
SELECT Territory, Year, Profit,
LEAD(Profit, 1, 0) OVER (PARTITION BY Year ORDER BY Territory) AS PrevProfit
FROM Profits
Explanation:
Verified answer as correct.
Reference: http://msdn.microsoft.com/en-us/library/hh231256.aspx
Reference: http://msdn.microsoft.com/en-us/library/hh213125.aspx
You use Microsoft SQL Server 2012 database to develop a shopping cart application. You need to rotate the
unique values of the ProductName field of a table-valued expression into multiple columns in the output. W hich
Transact-SQL operator should you use?
A.
CROSS JOIN
B.
CROSS APPLY
C.
PIVOT
D.
UNPIVOT
Explanation:
http://technet.microsoft.com/en-us/library/ms177634.aspx
You administer a Microsoft SQL Server database thatsupports a shopping application. You need to retrieve a
list of customers w ho live in territories that do not have a sales person. W hich Transact- SQL query or queries
should you use? (Each correct answ er presents a complete solution. Choose all that apply.)
A.
SELECT CustomerID FROM Customer
W HERE TerritoryID <> SOME(SELECT TerritoryID FROM Salesperson)
B.
SELECT CustomerID FROM Customer
WHERE TerritoryID <> ALL(SELECT TerritoryID FROM Salesperson)
C.
SELECT CustomerID FROM Customer
W HERE TerritoryID <> ANY(SELECT TerritoryID FROM Salesperson)
D.
SELECT CustomerID FROM Customer
WHERE TerritoryID NOT IN(SELECT TerritoryID FROM Salesperson)
Explanation:
Verified answer as correct.
Your database contains a table named SalesOrders. The table includes a DATETIME column named
OrderTime that stores the date and time each order is placed. There is a non-clustered index on the OrderTime
column. The business team w ants a report that displays the total number of orders placed on the current day.
You need to w rite a query that w ill return the correct results in the most efficient manner. W hich Transact-SQL
query should you use?
A.
SELECT COUNT(*) FROM SalesOrders
W HERE OrderTime = CONVERT(DATE, GETDATE())
B.
SELECT COUNT(*) FROM SalesOrders
W HERE OrderTime = GETDATE()
C.
SELECT COUNT(*) FROM SalesOrders
W HERE CONVERT(VARCHAR, OrderTime, 112) = CONVERT(VARCHAR, GETDATE(I, 112))
D.
SELECT COUNT(*) FROM SalesOrders
WHERE OrderTime >= CONVERT(DATE, GETDATE())
AND OrderTime < DATEADD(DAY, 1, CONVERT(DATE, GETDATE()))
Explanation:
Verified answer as correct.
Your application contains a stored procedure for each country. Each stored procedure accepts an employee
identification number through the @EmpID parameter.You plan to build a single process for each employee
that w ill execute the stored procedure based on thecountry of residence. W hich approach should you use?
A.
a recursive stored procedure
B.
Trigger
C.
An UPDATE statement that includes CASE
D.
Cursor
E.
The foreach SQLCLR statement
You use Microsoft SQL Server 2012 to develop a database application. You create a stored procedure named
dbo.ModifyData that can modify row s. You need to ensure that w hen the transaction fails, dbo.ModifyData
meets the follow ing requirements:
Does not return an error
Closes all opened transactions
W hich Transact-SQL statement should you use?
A.
BEGIN TRANSACTION
BEGIN TRY
EXEC dbo.ModifyData
COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF @@ TRANCOUNT = 0
ROLLBACK TRANSACTION;
END CATCH
B.
BEGIN TRANSACTION
BEGIN TRY
EXEC dbo.ModifyData
COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF @@ERROR != 0
ROLLBACK TRANSACTION;
THROW ;
END CATCH
C.
BEGIN TRANSACTION
BEGIN TRY
EXEC dbo.ModifyData
COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF @@TRANCOUNT = 0
ROLLBACK TRANSACTION;
THROW ;
END CATCH
D.
BEGIN TRANSACTION
BEGIN TRY
EXEC dbo.ModifyData
COMMIT TRANSACTION
END TRY
BEGIN CATCH
IF @@ERROR != 0
ROLLBACK TRANSACTION;
END CATCH
Explanation:
Verified answer as correct.
You need to ensure that throughout the transaction the data maintains the originalversion
Posted by seenagape on May 21, 2013 3 comments
You are developing a database application by using Microsoft SQL Server 2012. An application that usesa
database begins to run slow ly. You discover that during reads, the transaction experiences blocking from
concurrent updates. You need to ensure that throughout the transaction the data maintains the originalversion.
W hat should you do?
A.
B.
Add a LOOP hint to the query.
C.
Add a FORCESEEK hint to the query.
D.
Add an INCLUDE clause to the index.
E.
Add a FORCESCAN hint to the Attach query.
F.
Add a columnstore index to cover the query.
G.
Enable the optimize for ad hoc workloads option.
H.
Cover the unique clustered index with a columnstore index.
I.
Include a SET FORCEPLAN ON statement before you run the query.
J.
Include a SET STATISTICS PROFILE ON statement before you run the query.
K.
Include a SET STATISTICS SHOWPLAN_XML ON statement before you run the query.
L.
Include a SET TRANSACTION ISOLATION LEVEL REPEATABLE READ statement before you run the
query.
M.
Include a SET TRANSACTION ISOLATION LEVEL SNAPSHOT statement before you run the query.
N.
Include a SET TRANSACTION ISOLATION LEVEL SERIALIZABLE statement before you run the query.
You need to capture executionplans that will include detailed information on missing indexes
recommended by the query optimizer
Posted by seenagape on May 21, 2013 7 comments
You are developing a database application by using Microsoft SQL Server 2012. You have a query that runs
slow er than expected. You need to capture executionplans that w ill include detailed information on missing
indexes recommended by the query optimizer. W hat should you do?
A.
Add a HASH hint to the query.
B.
Add a LOOP hint to the query.
C.
Add a FORCESEEK hint to the query.
D.
Add an INCLUDE clause to the index.
E.
Add a FORCESCAN hint to the Attach query.
F.
Add a columnstore index to cover the query.
G.
Enable the optimize for ad hoc w orkloads option.
H.
Cover the unique clustered index w ith a columnstore index.
I.
Include a SET FORCEPLAN ON statement before you run the query.
J.
Include a SET STATISTICS PROFILE ON statement before you run the query.
K.
Include a SET STATISTICS SHOW PLAN_XML ON statement before you run the query.
L.
Include a SET TRANSACTION ISOLATION LEVEL REPEATABLE READ statement before you run the
query.
M.
Include a SET TRANSACTION ISOLATION LEVEL SNAPSHOT statement before you run the query.
N.
Include a SET TRANSACTION ISOLATION LEVEL SERIALIZABLE statement before you run the query.
You need to reduce procedure cacheusage from these statements without creating any additional
indexes
Posted by seenagape on May 21, 2013 No comments
You are developing a database application by using Microsoft SQL Server 2012. An application that usesa
database begins to run slow ly. You discover that a large amount of memory is consumed by single-use
dynamic queries. You need to reduce procedure cacheusage from these statements w ithout creating any
additional indexes. W hat should you do?
A.
Add a HASH hint to the query.
B.
Add a LOOP hint to the query.
C.
Add a FORCESEEK hint to the query.
D.
Add an INCLUDE clause to the index.
E.
Add a FORCESCAN hint to the Attach query.
F.
Add a columnstore index to cover the query.
G.
Enable the optimize for ad hoc workloads option.
H.
Cover the unique clustered index w ith a columnstore index.
I.
Include a SET FORCEPLAN ON statement before you run the query.
J.
Include a SET STATISTICS PROFILE ON statement before you run the query.
K.
Include a SET STATISTICS SHOW PLAN_XML ON statement before you run the query.
L.
Include a SET TRANSACTION ISOLATION LEVEL REPEATABLE READ statement before you run the
query.
M.
Include a SET TRANSACTION ISOLATION LEVEL SNAPSHOT statement before you run the query.
N.
Include a SET TRANSACTION ISOLATION LEVEL SERIALIZABLE statement before you run the query.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/cc645587.aspx
You are developing a database application by using Microsoft SQL Server 2012. An application that usesa
database begins to run slow ly. Your investigation show s the root cause is a query against a read-only table that
has a clustered index. The query returns the follow ing six columns:
One column in its W HERE clause contained in a non-clustered index Four additional columns
One COUNT (*) column based on a grouping of the four additional columns You need to optimize the
statement.
W hat should you do?
A.
Add a HASH hint to the query.
B.
Add a LOOP hint to the query.
C.
Add a FORCESEEK hint to the query.
D.
Add an INCLUDE clause to the index.
E.
Add a FORCESCAN hint to the Attach query.
F.
Add a columnstore index to cover the query.
G.
Enable the optimize for ad hoc w orkloads option.
H.
Cover the unique clustered index w ith a columnstore index.
I.
Include a SET FORCEPLAN ON statement before you run the query.
J.
Include a SET STATISTICS PROFILE ON statement before you run the query.
K.
Include a SET STATISTICS SHOW PLAN_XML ON statement before you run the query.
L.
Include a SET TRANSACTION ISOLATION LEVEL REPEATABLE READ statement before you run the
query.
M.
Include a SET TRANSACTION ISOLATION LEVEL SNAPSHOT statement before you run the query.
N.
Include a SET TRANSACTION ISOLATION LEVEL SERIALIZABLE statement before you run the query.
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. Tables are defined as show n in the
exhibit. (Refer to the Exhibit.)
You need to display row s from the Orders table for the Customers row having the CustomerId value set to 1 in
the follow ing XML format.
A.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers-CustomerId W HERE Customers.
CustomerId = 1
FOR XML RAW
B.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers.CustomerId
W HERE Customers=CustomerId = 1
FOR XML RAW , ELEMENTS
C.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers.CustomerId W HERE Customers.
CustomerId = 1
FOR XML AUTO
D.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId – Customers.CustomerId W HERE Customers.
CustomerId= 1
FOR XML AUTO, ELEMENTS
E.
SELECT Name, Country, OrderId, OrderDate, Amount FROM Orders INNER JOIN
Customers ON Orders.CustomerId= Customers.CustomerId W HERE 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 W HERE
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 W HERE
Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. Tables are defined as show n in the
exhibit. (Refer to the Exhibit.)
You need to display row s from the Orders table for the Customers row having the Customerld value set to 1 in
the follow ing XML format.
A.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers-CustomerId W HERE Customers.
CustomerId = 1
FOR XML RAW
B.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers.CustomerId W HERE Customers.
CustomerId = 1
FOR XML RAW , ELEMENTS
C.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId = Customers.CustomerId W HERE Customers.
CustomerId = 1
FOR XML AUTO
D.
SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN
Customers ON Orders.CustomerId – Customers.CustomerId W HERE Customers.
CustomerId= 1
FOR XML AUTO, ELEMENTS
E.
SELECT Name, Country, OrderId, OrderDate, Amount FROM Orders INNER JOIN
Customers ON Orders.CustomerId= Customers.CustomerId W HERE Customers.
CustomerId= 1
FOR XML AUTO
F.
SELECT Name, Country, Crderld, OrderDate, Amount FROM Orders INNER JOIN
Customers ON Orders.CustomerId= Customers.CustomerId W HERE 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 W HERE
Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
Explanation:
Verified answer as correct.
You use Microsoft SQL Server 2012 to w rite code fora transaction that contains several statements. There is
high contention betw een readers and w riters on several tables used by your transaction. You need to minimize
the use of the tempdb space. You also need to prevent reading queries from blocking w riting queries. W hich
isolation level should you use?
A.
SERIALIZABLE
B.
SNAPSHOT
C.
READ COMMITTED SNAPSHOT
D.
REPEATABLE READ
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms173763.aspx
You create a table that has the StudentCode, SubjectCode, and Marks columns to record mid-year marks for
students. The table has marks obtained by 50 students for various subjects. You need to ensure that the top
half of the students arranged by their average marks must be given a rank of 1 and the remaining students
must be given a rank of 2. W hich Transact-SQL queryshould you use?
A.
SELECT StudentCode as Code,
RANK() OVER (ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
B.
SELECT Id, Name, Marks,
DENSE_RANK() OVER (ORDER BY Marks DESC) AS Rank
FROM StudentMarks
C.
SELECT StudentCode as Code,
DENSE_RANK() OVER (ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
D.
SELECT StudentCode as Code,
NTILE (2) OVER (ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
E.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER (PARTITION BY SubjectCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
F.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER (PARTITION BY SubjectCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
G.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK () OVER (PARTITION BY StudentCode ORDER BYMarks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
H.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANXO OVER (PARTITION BY StudentCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
You create a table that has the StudentCode, SubjectCode, and Marks columns to record mid-year marks for
students. The table has marks obtained by 50 students for various subjects. You need to ensure that the
follow ing requirements are met:
Students must be ranked based on their average marks.
If one or more students have the same average, the same rank must be given to these students.
Consecutive ranks must be skipped w hen the same rank is assigned.
W hich Transact-SQL query should you use?
A.
SELECT StudentCode as Code,
RANK() OVER(ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
B.
SELECT Id, Name, Marks,
DENSE_RANK() OVER(ORDER BY Marks DESC) AS Rank
FROM StudentMarks
C.
SELECT StudentCode as Code,
DENSE_RANK() OVER(ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
D.
SELECT StudentCode as Code,
NTILE(2) OVER(ORDER BY AVG (Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
E.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
F.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
G.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY StudentCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
H.
SELECT StudentCode AS Code,Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANXO OVER(PARTITION BY StudentCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms189798.aspx
You create a table that has the StudentCode, SubjectCode, and Marks columns to record mid-year marks for
students. The table has marks obtained by 50 students for various subjects. You need to retrieve the students
w ho scored the highest marks for each subject alongw ith the marks. W hich Transact-SQL query should you
use?
A.
SELECT StudentCode as Code, RANK() OVER(ORDER BY AVG(Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
B.
SELECT Id, Name, Marks, DENSE_RANK() OVER(ORDER BY Marks DESC) AS Rank
FROM StudentMarks
C.
SELECT StudentCode as Code, DENSE_RANK() OVER(ORDERBY AVG(Marks) DESC) AS
Value
FROM StudentMarks
GROUP BY StudentCode
D.
SELECT StudentCode as Code, NTILE(2) OVER(ORDER BY AVG(Marks) DESC) AS Value
FROM StudentMarks
GROUP BY StudentCode
E.
SELECT StudentCode AS Code, Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
F.
SELECT StudentCode AS Code, Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY SubjectCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
WHERE Rank = 1
G.
SELECT StudentCode AS Code, Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANK() OVER(PARTITION BY StudentCode ORDER BY Marks ASC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
H.
SELECT StudentCode AS Code, Marks AS Value FROM (
SELECT StudentCode, Marks AS Marks,
RANXO OVER(PARTITION BY StudentCode ORDER BY Marks DESC) AS Rank
FROM StudentMarks) tmp
W HERE Rank = 1
You need to store the departure and arrival dates and times of flights along with time zone
information
Posted by seenagape on May 21, 2013 No comments
You develop a database for a travel application. You need to design tables and other database objects.You
create the Airline_Schedules table. You need to store the departure and arrival dates and times of flights along
w ith time zone information. W hat should you do?
A.
Use the CAST function.
B.
Use the DATE data type.
C.
Use the FORMAT function.
D.
Use an appropriate collation.
E.
Use a user-defined table type.
F.
Use the VARBINARY data type.
G.
Use the DATETIME data type.
H.
Use the DATETIME2 data type.
I.
Use the DATETIMEOFFSET data type.
J.
Use the TODATETIMEOFFSET function.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ff848733.aspx
Reference: http://msdn.microsoft.com/en-us/library/bb630289.aspx
You need to supply the stored procedure with multiple event names and theirdates as parameters
Posted by seenagape on May 21, 2013 No comments
You develop a database for a travel application. You need to design tables and other database objects.You
create a stored procedure. You need to supply the stored procedure w ith multiple event names and theirdates
as parameters. W hat should you do?
A.
Use the CAST function.
B.
Use the DATE data type.
C.
Use the FORMAT function.
D.
Use an appropriate collation.
E.
Use a user-defined table type.
F.
Use the VARBINARY data type.
G.
Use the DATETIME data type.
H.
Use the DATETIME2 data type.
I.
Use the DATETIMEOFFSET data type.
J.
Use the TODATETIMEOFFSET function.
You develop a Microsoft SQL Server 2012 database. The database is used by tw o w eb applications that access
a table named Products. You w ant to create an object that w ill prevent the applications from accessingthe table
directly w hile still providing access to the required data. You need to ensure that the follow ing requirements are
met:
Future modifications to the table definition w ill not affect the applications’ ability to access data.
The new object can accommodate data retrieval and data modification.
You need to achieve this goal by using the minimum amount of changes to the applications.
W hat should you create for each application?
A.
Synonyms
B.
Common table expressions
C.
Views
D.
Temporary tables
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms190174.aspx
Which object should you use?
Posted by seenagape on May 21, 2013 3 comments
You use Microsoft SQL Server 2012 to develop a database application. You need to create an object that
meets the follow ing requirements:
Takes an input variable
Returns a table of values
Cannot be referenced w ithin a view
W hich object should you use?
A.
Scalar-valued function
B.
Inline function
C.
User-defined data type
D.
Stored procedure
You are a database developer for an application hosted on a Microsoft SQL Server 2012 server. The database
contains tw o tables that have the follow ing definitions:
Global customers place orders from several countries. You need to view the country from w hich each customer
has placed the most orders. W hich Transact-SQL query do you use?
A.
SELECT c.CustomerID, c.CustomerName, o.ShippingCountry
FROM Customer c
INNER JOIN
(SELECT CustomerID, ShippingCountry,
RANK() OVER (PARTITION BY CustomerID
ORDER BY COUNT(OrderAmount) DESC) AS Rnk
FROM Orders
GROUP BY CustomerID, ShippingCountry) AS o
ON c.CustomerID = o.CustomerID
WHERE o.Rnk = 1
B.
SELECT c.CustomerID, c.CustomerName, o.ShippingCountry
FROM
(SELECT c.CustomerID, c.CustomerName, o.ShippingCountry,
RANK() OVER (PARTITION BY CustomerID
ORDER BY COUNT(o.OrderAmount) ASC) AS Rnk
FROM Customer c
INNER JOIN Orders o
ON c.CustomerID = o.CustomerID
GROUP BY c.CustomerID, c.CustomerName, o.ShippingCountry) cs
W HERE Rnk = 1
C.
SELECT c.CustomerID, c.CustomerName, o.ShippingCountry
FROM Customer c
INNER JOIN
(SELECT CustomerID, ShippingCountry,
RANK() OVER (PARTITION BY CustomerID
ORDER BY OrderAmount DESC) AS Rnk
FROM Orders
GROUP BY CustomerID, ShippingCountry) AS o
ON c.CustomerID = o.CustomerID
W HERE o.Rnk = 1
D.
SELECT c.CustomerID, c.CustomerName, o.ShippingCountry
FROM Customer c
INNER JOIN
(SELECT CustomerID, ShippingCountry,
COUNT(OrderAmount) DESC) AS OrderAmount
FROM Orders
GROUP BY CustomerID, ShippingCountry) AS o
ON c.CustomerID = o.CustomerID
ORDER BY OrderAmount DESC
Explanation:
Verified answer as correct.
You w ant to add a new GUID column named BookGUID toa table named dbo.Book that already contains data.
BookGUID w ill have a constraint to ensure that it alw ays has a value w hen new row s are inserted into dbo.
Book. You need to ensure that the new column is assigned a GUID for existing row s. W hich four Transact-SQL
statements should you use? (To answ er, move the appropriate SQL statements from the list of statementsto
the answ er area and arrange them in the correct order.)
Answ er:
Explanation:
You grant the Select permission to User1 for this view . You need to change the view so that it display s only the
records that w ere processed in the month prior to the current month. You need to ensure that after the
changes, the view functions correctly for User1. W hich four Transact-SQL statements should you use? (To
answ er, move the appropriate SQL statements from the list of statements to the answ er area and arrangethem
in the correct order.)
Answ er:
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/hh213020.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms186819.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms173846.aspx
You use a Microsoft SQL Server 2012 database. You need to create an indexed view w ithin the database for a
report that displays Customer Name and the total revenue for that customer. W hich four T-SQL statements
should you use? (To answ er, move the appropriate SQL statements from the list of statements to the answ er
area and arrange them in the correct order.)
Answ er:
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms191432.aspx
You administer a Microsoft SQL Server 2012 database. You use an OrderDetail table that has the follow ing
definition:
You need to create a non-clustered index on the SalesOrderID column in the OrderDetail table to include only
row s that contain a value in the SpecialOfferID column. W hich four Transact-SQL statements should you use?
(To answ er, move the appropriate statements from the list of statements to the answ er area and arrangethem
in the correct order.)
Answ er:
Explanation:
You need to implement a computed column that references a lookup table by using an INNER JOIN
against another table
Posted by seenagape on May 21, 2013 1 comment
You use Microsoft SQL Server 2012 to develop a database application. You need to implement a computed
column that references a lookup table by using an INNER JOIN against another table.
W hat should you do?
A.
Reference a user-defined function within the computed column.
B.
Create a BEFORE trigger that maintains the state of the computed column.
C.
Add a default constraint to the computed column that implements hard-coded values.
D.
Add a default constraint to the computed column that implements hard-coded CASE statements.
Explanation:
Verified answer as correct.
Exam C
You administer a Microsoft SQL Server 2012 databasenamed ContosoDb. The database contains a table
named Suppliers and a column named IsActive in the Purchases schema. You create a new user named
ContosoUser in ContosoDb. ContosoUser has no permissions to the Suppliers table. You need to ensure that
ContosoUser can delete row s that are not active from Suppliers. You also need to grant ContosoUser only the
minimum required permissions. W hich Transact-SQL statement should you use?
A.
GRANT DELETE ON Purchases.Suppliers TO ContosoUser
B.
CREATE PROCEDURE Purchases.PurgeInactiveSuppliers
W ITH EXECUTE AS USER = ‘dbo’
AS
DELETE FROM Purchases.Suppliers W HERE IsActive = 0
GO
GRANT EXECUTE ON Purchases.PurgelnactiveSuppliers TO ContosoUser
C.
GRANT SELECT ON Purchases.Suppliers TO ContosoUser
D.
CREATE PROCEDURE Purchases.PurgeInactiveSuppliers
AS
DELETE FROM Purchases.Suppliers WHERE IsActive = 0
GO
GRANT EXECUTE ON Purchases.PurgeInactiveSuppliers TO ContosoUser
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms188354.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms187926.aspx
You use a contained database named ContosoDb w ithina domain. You need to create a user w ho can log on
to the ContosoDb database. You also need to ensure that you can port the database to different database
servers w ithin the domain w ithout additional user account configurations. W hich type of user should you
create?
A.
User mapped to a certificate
B.
SQL user w ithout login
C.
Domain user
D.
SQL user w ith login
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ff929071.aspx
You need to achieve this goal by using the minimum amount of administrative effort
Posted by seenagape on May 21, 2013 No comments
You administer a Microsoft SQL Server 2012 databasethat has multiple tables in the Sales schema. Some
users must be prevented from deleting records in any of the tables in the Sales schema. You need to manage
users w ho are prevented from deleting records in the Sales schema. You need to achieve this goal by using the
minimum amount of administrative effort. W hat should you do?
A.
Create a custom database role that includes the users. Deny Delete permissions on the Sales schema
for
the custom database role.
B.
Include the Sales schema as an ow ned schema for the db_denydataw riter role. Add the users to the
db_denydataw riter role.
C.
Deny Delete permissions on each table in the Sales schema for each user.
D.
Create a custom database role that includes the users. Deny Delete permissions on each table in the Sales
schema for the custom database role.
Explanation:
Looks good.
You need to ensure that the minimum amount of disk space is used to store the data in the Product
table
Posted by seenagape on May 21, 2013 No comments
You administer a Microsoft SQL Server 2012 database. The database contains a Product table created by
using the follow ing definition:
You need to ensure that the minimum amount of disk space is used to store the data in the Product table. W hat
should you do?
A.
Convert all indexes to Column Store indexes.
B.
Implement Unicode Compression.
C.
Implement row -level compression.
D.
Implement page-level compression.
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/cc280449.aspx
Reference: http://msdn.microsoft.com/en-us/library/cc280464.aspx
Reference: http://msdn.microsoft.com/en-us/library/cc280576.aspx
Reference: http://msdn.microsoft.com/en-us/library/ee240835.aspx
You need to improve the performance of the query. W hat should you do?
A.
Drop the UDF and rewrite the report query as follows:
WITH cte(CustomerID, LastOrderDate) AS (
SELECT CustomerID, MAX(OrderDate) AS [LastOrderDate]
FROM Sales.SalesOrder
GROUP BY CustomerID
)
SELECT c.CustomerName
FROM cte
INNER JOIN Sales.Customer c
ON cte.CustomerID = c.CustomerID
WHERE cte.LastOrderDate < DATEADD(DAY, -90, GETDATE())
B.
Drop the UDF and rew rite the report query as follow s:
SELECT c.CustomerName
FROM Sales.Customer c
W HERE NOT EXISTS (
SELECT s.OrderDate
FROM Sales.SalesOrder
W HERE s.OrderDate > DATEADD(DAY, -90, GETDATE())
AND s.CustomerID = c.CustomerID)
C.
Drop the UDF and rew rite the report query as follow s:
SELECT DISTINCT c.CustomerName
FROM Sales.Customer c
INNER JOIN Sales.SalesOrder s
ON c.CustomerID = s.CustomerID
W HERE s.OrderDate < DATEADD(DAY, -90, GETDATE())
D.
Rew rite the report query as follow s:
SELECT c.CustomerName
FROM Sales.Customer c
W HERE NOT EXISTS (SELECT OrderDate FROM Sales.ufnGetRecentOrders(c.CustomerID,
90))
Rew rite the UDF as follow s:
CREATE FUNCTION Sales.ufnGetRecentOrders(@CustomerID int, @MaxAge datetime)
RETURNS TABLE AS RETURN (
SELECT OrderDate
FROM Sales.SalesOrder
W HERE s.CustomerID = @CustomerID
AND s.OrderDate > DATEADD(DAY, -@MaxAge, GETDATE())
You develop a database application for a university. You need to create a view that w ill be indexed that meets
the follow ing requirements:
Displays the details of only students from Canada.
Allow s insertion of details of only students from Canada.
W hich four Transact-SQL statements should you use? (To answ er, move the appropriate SQL statements from
the list of statements to the answ er area and arrange them in the correct order.)
Answ er:
Explanation:
You create the follow ing stored procedure. (Line numbers are included for reference only.)
You need to ensure that the stored procedure performs the follow ing tasks:
If a record exists, update the record.
If no record exists, insert a new record.
W hich four Transact-SQL statements should you insert at line 07? (To answ er, move the appropriate
statements from the list of statements to the answ er area and arrange them in the correct order.)
Answ er:
Explanation:
Reference: http://technet.microsoft.com/en-us/library/bb510625.aspx
You use Microsoft SQL Server 2012 to develop a database application. You create tw o tables by using the
follow ing table definitions.
W hich six Transact-SQL statements should you use? (To answ er, move the appropriate SQL statements from
the list of statements to the answ er area and arrange them in the correct order.)
Answ er:
Explanation:
You use Microsoft SQL Server 2012 to develop a database application. You create a table by using the
follow ing definition:
CREATE TABLE Prices (
PriceId int IDENTITY(1,1) PRIMARY KEY,
ActualPrice NUMERIC(16,9),
PredictedPrice NUMERIC(16,9)
)
You need to create a computed column based on a user-defined function named udf_price_index. You also
need to ensure that the column supports an index. W hich three Transact-SQL statements should you use? (To
answ er, move the appropriate SQL statements from the list of statements to the answ er area and arrangethem
in the correct order.)
Answ er:
Explanation:
Which three Transact-SQL statements should you use?
Posted by seenagape on May 21, 2013 No comments
You use Microsoft SQL Server 2012 to develop a database that has tw o tables named Div1Cust and Div2Cust.
Each table has columns named DivisionID and CustomerId . None of the row s in Div1Cust exist in Div2Cust.
You need to w rite a query that meets the follow ing requirements:
The row s in Div1Cust must be combined w ith the row sin Div2Cust.
The result set must have columns named Division andCustomer.
Duplicates must be retained.
W hich three Transact-SQL statements should you use?(To answ er, move the appropriate statements from the
list of statements to the answ er area and arrange them in the correct order.)
Answ er:
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms180026.aspx
Reference: http://msdn.microsoft.com/en-us/library/ms188055.aspx
Exam D
You administer a Microsoft SQL Server 2012 databasethat contains a table named OrderDetail. You discover
that the NCI_OrderDetail_CustomerID non-clustered index is fragmented. You need to reduce fragmentation.
You need to achieve this goal w ithout taking the index offline. W hich Transact-SQL batch should you use?
A.
CREATE INDEX NCI_OrderDetail_CustomerID ON OrderDetail.CustomerID W ITH DROP
EXISTING
B.
ALTER INDEX NCI_OrderDetail_CustomerID ON OrderDetail.CustomerID REORGANIZE
C.
ALTER INDEX ALL ON OrderDetail REBUILD
D.
ALTER INDEX NCI_OrderDetail_CustomerID ON OrderDetail.CustomerID REBUILD
Explanation:
Reference: http://msdn.microsoft.com/en-us/library/ms188388.aspx
You develop a Microsoft SQL Server 2012 database. The database is used by tw o w eb applications that access
a table named Products. You w ant to create an object that w ill prevent the applications from accessingthe table
directly w hile still providing access to the required data. You need to ensure that the follow ing requirements are
met:
Future modifications to the table definition w ill not affect the applications’ ability to access data.
The new object can accommodate data retrieval and data modification.
You need to achieve this goal by using the minimum amount of changes to the existing applications.
W hat should you create for each application?
A.
views
B.
table partitions
C.
table-valued functions
D.
stored procedures
You develop a Microsoft SQL Server 2012 database. You need to create a batch process that meets the
follow ing requirements:
Returns a result set based on supplied parameters.
Enables the returned result set to perform a join w ith a table.
W hich object should you use?
A.
Inline user-defined function
B.
Stored procedure
C.
Table-valued user-defined function
D.
Scalar user-defined function
A.
CREATE PROCEDURE dbo.GetCustomerRating @Customer INT, @CustomerRatIng INT OUTPUT
AS
SET NOCOUNT ON SELECT @CustomerRating = CustomerOrders/CustomerValue
FROM Customers WHERE CustomerID = @CustomerID
RETURN
GO
B.
EXECUTE dbo.GetCustomerRatIng 1745
C.
DECLARE @customerRatingBycustomer INT
DECLARE @Result INT
EXECUTE @Result = dbo.GetCustomerRating
1745
, @CustomerRatingSyCustomer
D.
CREATE PROCEDURE dbo.GetCustomerRating @CustomerID INT, @CustomerRating INT OUTPUT
AS
SET NOCOUNT ON
SELECT @Result = CustomerOrders/CustomerValue
FROM Customers W HERE CustomerID = @CustomeriD
RETURN @Result
GO
E.
DECLARE @CustomerRatIngByCustcmer INT
EXECUTE dbo.GetCustomerRating @CustomerID = 1745,
@CustomerRating = @CustomerRatingByCustomer OUTPUT
F.
CREATE PROCEDURE dbo.GetCustomerRating
@CustomerID INT
AS
DECLARE @Result INT
SET NOCOUNT ON
SELECT @Result = CustomerOrders/CustomerVaLue
FROM Customers
W HERE Customer= = @CustomerID
RETURNS @Result
Explanation:
Correct answer AE (see comments and try by yourself) Ax