Ensurepass

QUESTION 171

You use Microsoft SQL Server 2012 to develop a database application. You need to create an object that meets the following requirements:

 

– Takes an input variable

– Returns a table of values

– Cannot be referenced within a view

 

Which object should you use?

 

A.

Scalar-valued function

B.

Inline function

C.

User-defined data type

D.

Stored procedure

 

Correct Answer: D

 

 

QUESTION 172

You administer a SQL Server 2012 server that contains a database named SalesDb. SalesDb contains a schema named Customers that has a table named Regions. A user named UserA is a member of a role named Sales. UserA is granted the Select permission on the Regions table. The Sales role is granted the Select permission on the Customers schema.

You need to ensure that the following requirements are met:

The Sales role does not have the Select permission on the Customers schema.

UserA has the Select permission on the Regions table.

Which Transact-SQL statement should you use?

 

A.

DENY SELECT ON Object::Regions FROM Sales

B.

DENY SELECT ON Schema::Customers FROM Sales

C.

REVOKE SELECT ON Object::Regions FROM Sales

D.

REVOKE SELECT ON Schema::Customers FROM Sales

E.

DENY SELECT ON Object::Regions FROM UserA

F.

DENY SELECT ON Schema::Customers FROM UserA

G.

REVOKE SELECT ON Object::Regions FROM UserA

H.

REVOKE SELECT ON Schema::Customers FOR UserA

I.

EXEC sp_addrolemember ‘Sales’, ‘UserA’

J.

EXEC sp_droprolemember ‘Sales’, ‘UserA’

 

Correct Answer: D

Explanation:

http://msdn.microsoft.com/en-us/library/ms188369.aspx

http://msdn.microsoft.com/en-us/library/ms187750.aspx

http://msdn.microsoft.com/en-us/library/ff848791.aspx

 

 

QUESTION 173

You develop a Microsoft SQL Server 2012 database that contains a heap named OrdersHistoncal. You write the following Transact-SQL query:

 

INSERT INTO OrdersHistorical

SELECT * FROM CompletedOrders

 

You need to optimize transaction logging and locking for the statement. Which table hint should you use?

 

A.

HOLDLOCK

B.

ROWLOCK

C.

XLOCK

D.

UPDLOCK

E.

TABLOCK

 

Correct Answer: E

Explanation:

http://technet.microsoft.com/en-us/library/ms189857.aspx

http://msdn.microsoft.com/en-us/library/ms187373.aspx

 

 

QUESTION 174

Your database contains a table named Purchases. The table 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 wants a report that displays the total number of purchases made on the current day. You need to write a query that will return the correct results in the most efficient manner.

 

Which Transact-SQL query should you use?

 

A.

SELECT COUNT(*)

FROM Purchases

WHERE PurchaseTime = CONVERT(DATE, GETDATE())

B.

SELECT COUNT(*)

FROM Purchases

WHERE PurchaseTime = GETDATE()

C.

SELECT COUNT(*)

FROM Purchases

WHERE 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()))

 

Correct Answer: D

Explanation:

http://technet.microsoft.com/en-us/library/ms181034.aspx

 

QUESTION 175

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 will require fast access and will be retrieved frequently. What 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.

 

Correct Answer: F

Explanation:

http://msdn.microsoft.com/en-us/library/ms188362.aspx

 

 

QUESTION 176

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. What 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.

 

Correct Answer: C

Explanation:

http://msdn.microsoft.com/en-us/library/hh213505.aspx

 

 

QUESTION 177

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 following definition:

You need to ensure that users can update only the phone numbers by using this view.

What should you do?

 

A.

Alter the view. Use the EXPAND VIEWS query hint along with 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.

 

Correct Answer: D

 

 

QUESTION 178

You develop a Microsoft SQL Server 2012 database that contains tables named Employee and Person. The tables have the following definitions:

 

70-462-demo-109

 

You create a view named VwEmployee as shown in the following Transact-SQL statement.

 

70-462-demo-110

 

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 VwEmployee view.

Which Transact-SQL statement should you use?

 

A.

CREATE TRIGGER TrgVwEmployee

ON VwEmployee

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 TrgVwEmployee

ON VwEmployee

INSTEAD OF INSERT

AS

BEGIN

DECLARE @ID INT, @FirstName NVARCHAR(25), @LastName NVARCHAR(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 TrgVwEmployee

ON VwEmployee

INSTEAD OF INSERT

AS

BEGIN

INSERT INTO Person(Id, FirstName, LastName)

SELECT Id, FirstName, LastName FROM VwEmployee

INSERT INTO Employee(PersonID, EmployeeNumber)

SELECT Id, EmployeeNumber FROM VwEmployee

End

 

Correct Answer: B

 

 

 

 

QUESTION 179

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 improve the performance of the view by persisting data to disk. What 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 WITH VIEW_METADATA clause.

D.

Create a clustered index on the view.

 

Correct Answer: D

Explanation:

http://msdn.microsoft.com/en-us/library/ms188783.aspx

 

 

QUESTION 180

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 NewPrice. The ProductsPriceLog table stores the previous price in the OldPrice column and the new price in the NewPrice 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. Which Transact-SQL query 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, NewPrice)

C.

UPDATE Products SET Price = Price * 1.05

OUTPUT inserted.ProductCode, deleted.Price, inserted.Price * INTO ProductsPriceLog(ProductCode,

OldPrice, NewPrice)

D.

UPDATE Products SET Price = Price * 1.05

INSERT INTO ProductsPriceLog (ProductCode, CldPnce, NewPrice; SELECT ProductCode, Price,

Price * 1.05 FROM Products

 

Correct Answer: A

Explanation:

http://msdn.microsoft.com/en-us/library/ms177564.aspx

 

Instant Access to Download Latest Complete Collection of Microsoft MCSA 70-462 Real Exam

Try Microsoft MCSA 70-462 Free Demo

Leave a Reply

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

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