Exam4Training

Microsoft 70-461 Querying Microsoft SQL Server 2012 Online Training

Question #1

You use a Microsoft SQL Server database that contains a table.

The table has records of web requests as shown in the exhibit. (Click the Exhibit button.)

Your network has three web servers that have the following IP addresses:

– 10.0.0.1

– 10.0.0.2

– 10.0.0.3

You need to create a query that displays the following information:

– The number of requests for each web page (UriStem) grouped by the web server (ServerIP) that served the request

– A column for each server

Which Transact-SQL query should you use?

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

PIVOT rotates a table-valued expression by turning the unique values from one column in the expression into multiple columns in the output, and performs aggregations where they are required on any remaining column values that are wanted in the final output.

References: https://docs.microsoft.com/en-us/sql/t-sql/queries/from-using-pivot-and­unpivot?view=sql-server-2017

Question #2

DRAG DROP

You develop a Microsoft SQL Server database for a sales ordering application.

You want to create a report that displays the increase of order quantities over the previous year for each product.

You need to write a query that displays:

– Product name,

– Year of sales order,

– Sales order quantity, and

– Increase of order quantity over the previous year.

Which three Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: FROM ..

Box 2: LAG (not LEAD)

Lag accesses data from a previous row in the same result set without the use of a self-join starting

with SQL Server 2012 (11.x). LAG provides access to a row at a given physical offset that comes before the current row. Use this analytic function in a SELECT statement to compare values in the current row with values in a previous row.

Not lead: Lead accesses data from a subsequent row in the same result set without the use of a self-join starting with SQL Server 2012 (11.x). LEAD provides access to a row at a given physical offset that follows the current row.

Box 3: GROY BY PRO.NAME, YEAR (OrderDate)

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/lag-transact-sql?view=sql-server­2017


Question #3

You develop a Microsoft SQL Server database that contains a table named Employee, defined as follows:

You need to create a view that contains two computed columns representing the month and the year of the [HireDate] of each Employee.

Which function should you use?

  • A . DATENAME( )
  • B . CONVERT( )
  • C . TRYDATEDIFF( )
  • D . MONTH( ) and YEAR( )

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

The Month function returns an integer that represents the month of the specified date.

The Year function an integer that represents the year of the specified date.

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/month-transact-sql?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/t-sql/functions/year-transact-sql?view=sql-server-2017

Question #4

You administer a Microsoft SQL Server database named ContosoDb.

The database has the following schema collection:

The database has a table named ReceivedPurchaseOrders that includes an XML column named PurchaseOrder by using the above schema.

You need to set the requiresApproval attribute of the XML documents to false if they contain more than 50 items.

Which Transact-SQL query should you run?

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

Replace value of (XML DML) updates the value of a node in the document.

Example: — update text in the first manufacturing step

SET @myDoc.modify(‘

replace value of (/Root/Location/step[1]/text())[1]

with "new text describing the manu step"

‘);

Question #5

DRAG DROP

Your Microsoft SQL Server database contains tables as shown below.

You have tables that were created by running the following Transact-SQL statements:

The Product table contains 10,000 records. The maximum ProductID is 11,000.

There are 12 rows in the Category table. The maximum CategoryID is 12.

The Product table contains at least one product in every category.

Data in the tables was accidently modified. To correct this, you need to make some updates directly to the tables. You issue several statements.

Which result or results will you obtain for each Transact-SQL statement? To answer, drag the appropriate results to the correct Transact-SQL statements. Each result may be used once. More than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: The SET IDENTITY_INSERT command allows explicit values to be inserted into the identity column of a table.

Box 2: The Product table contains at least one product in every category.

Box 3:

Box 4: Bit is a data type that can take a value of 1, 0, or NULL.

References: https://docs.microsoft.com/en-us/sql/t-sql/data-types/bit-transact-sql?view=sql-server-2017 https://docs.microsoft.com/en-us/sql/t-sql/statements/set-identity-insert-transact-sql?view=sql­server-2017


Question #6

DRAG DROP

You develop an application that uses data from a Microsoft SQL Server database.

Your application experiences blocking problems.

You need to enable row versioning and you want connections to have row versioning enabled by default.

How should you complete the Transact-SQL statement? To answer, drag the appropriate command to the correct positions. Each command may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

You can use a row versioning-based isolation level.

Set READ_COMMITTED_SNAPSHOT database option ON to enable read-committed transactions to use row versioning, and use snapshot isolation.

References: https://docs.microsoft.com/en-us/sql/relational-databases/sql-server-transaction­locking-and-row-versioning-guide?view=sql-server-2017


Question #7

DRAG DROP

You are a developer for a Microsoft SQL Server database. You need to write a stored procedure that performs several operations in the most efficient way possible.

Which operator or operators should you use? To answer, drag the appropriate operators to the correct operations. Each operator may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: UNION ALL

UNION combines the results of two or more queries into a single result set that includes all the rows that belong to all queries in the union.

UNION ALL Incorporates all rows into the results. This includes duplicates. If ALL is not specified, duplicate rows are removed.

Box 2: INTERSECT

INTERSECT returns distinct rows that are output by both the left and right input queries operator.

Box 3: INNER JOIN

The INNER JOIN keyword selects records that have matching values in both tables.

Box 4: MERGE

Merge performs insert, update, or delete operations on a target table based on the results of a join with a source table. For example, you can synchronize two tables by inserting, updating, or deleting rows in one table based on differences found in the other table.

Box 5: FULL OUTER JOIN

The FULL OUTER JOIN keyword return all records when there is a match in either left (table1) or right (table2) table records.

Note: FULL OUTER JOIN can potentially return very large result-sets!


Question #8

You develop a database application for Microsoft SQL Server and Microsoft Azure SQL Database.

You need to raise an exception and transfer execution to a CATCH block.

You need to ensure that the exception returns output in the following format:

Msg 51000, Level 16, State 1, Line 1

The record does not exist.

Which Transact-SQL statement should you run?

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The following example shows how to use the THROW statement to raise an exception.

THROW 51000, ‘The record does not exist.’, 1;

Here is the result set.

Msg 51000, Level 16, State 1, Line 1

The record does not exist.

References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact­sql?view=sql-server-2017

Question #9

DRAG DROP

You develop a database application for Microsoft SQL Server 2012 and Microsoft Azure SQL Database.

You create a table named Purchasing.vVendorWithAddresses as shown in the following table.

You write the following Transact-SQL (Line numbers are included for reference only.) 01 CREATE PROCEDURE

You need to add Transact-SQL statements at line 08 to ensure that GetVendorInStateNeighbors returns the names of vendors that are located in all states where the vendor specified in the @vendorname parameter has a location.

Which three Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

The IN statement determines whether a specified value matches any value in a subquery or a list.

Incorrect: The EXISTS command specifies a subquery to test for the existence of rows.

References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/in-transact­sql?view=sql-server-2017


Question #10

A local bank uses a SQL Server database to manage accounts. You are developing a stored procedure that contains multiple Transact-SQL INSERT statements. The stored procedure must use transaction management to handle errors. You need to ensure that the stored procedure rolls back the entire transaction if a run-time occurs.

Which Transact-SQL statement should you add to the stored procedure?

  • A . SET ARITHABORT ON
  • B . SET NOEXEC ON
  • C . SET TRANSACTION ISOLATION LEVEL ON
  • D . SET XACT_ABORT ON

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

SET XACT_ABORT specifies whether SQL Server automatically rolls back the current transaction when a Transact-SQL statement raises a run-time error.

When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back.

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact­sql?view=sql-server-2017

Question #11

DRAG DROP

You are the administrator for a heavily-used OLTP Microsoft SQL Server database.

You are troubleshooting performance issues seen when using stored procedures in the database. The database stores millions of orders across thousands of customers. Some of the customers have large numbers of orders, while others have only one order. You update the statistics and perform defragmentation of all tables and indexes, but two stored procedures still have issues when accessing data.

p_GetCustomer accepts @companyID as a parameter. From the results of profiling, you know that 90 percent of the calls use the @companyid value of 5, while the other 10 percent of calls are evenly distributed across another 10000 values. While viewing the execution plan, you discover that a non-clustered index seek is used.

p_GetShipDate accepts @orderID as a parameter and returns the ship date for that order. You discover that the execution plan is performing a scan on a non-clustered index that has orderID as the index key.

You need to add appropriate query hints to each stored procedure to improve the performance.

What should you do? To answer, drag the appropriate procedures to the correct hints. Each procedure may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: Optimize FOR..

OPTIMIZE FOR ( @variable_name { UNKNOWN | = literal_constant } [ , …n ] ) Instructs the query optimizer to use a particular value for a local variable when the query is compiled and optimized. The value is used only during query optimization, and not during query execution.

Box 2: FORCESEEK

FORCESEEK [ (index_value(index_column_name [ ,… n ] )) ] Specifies that the query optimizer use only an index seek operation as the access path to the data in the table or view.

References: https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-query?view=sql-server-2017

https://docs.microsoft.com/en-us/sql/t-sql/queries/hints-transact-sql-table?view=sql-server-2017


Question #12

You use Microsoft SQL Server to develop a database application. Your application sends data to a VARCHAR (50) variable named @var. You need to write a Transact-SQL statement that will return information on a successful or

unsuccessful cast to an integer in a table.

Which Transact-SQL statement should you run?

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

TRY_PARSE returns the result of an expression, translated to the requested data type, or null if the cast fails in SQL Server. Use TRY_PARSE only for converting from string to date/time and number types.

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/try-parse-transact-sql?view=sql­server-2017

Question #13

DRAG DROP

You are developer for a Microsoft Azure SQL Database instance.

You are creating a new stored procedure. The procedure must perform the following tasks in this order: -1. Update a table named OrderHistory. -2. Delete rows from a table named Orders. -3. Delete rows from a table named Customers. -4. Insert rows into a table named ProcessHistory.

You need to ensure that the procedure meets the following requirements:

-If either DELETE operation fails, the rest of operation must continue. -If either the UPDATE operation or the INSERT operation fails, the whole procedure should fail and no changes should be retained.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back.

When SET XACT_ABORT is OFF, in some cases only the Transact-SQL statement that raised the error is rolled back and the transaction continues processing.

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/set-xact-abort-transact­sql?view=sql-server-2017


Question #14

CORRECT TEXT

You have a SQL Server database that contains all of the sales data for your company.

You need to create a query that returns the customers who represent the top five percent of the total actual sales.

Part of the correct Transact-SQL has been provided in the answer area below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements. You can add code within the code that has been provided as well as below it.

Use the Check Syntax button to verify your work. Any syntax or spelling errors will be reported by

line and character position.

Reveal Solution Hide Solution

Correct Answer: Please review the explanation part for this answer

Explanation:

1 SELECT CustomerID, N

2 ,Top5= TOP (0,95) PERCENT Sales (ORDER BY N) OVER (PARTITION BY Sales)

3 FROM Customers;

Add TOP and PERCENT Sales on line 2.

Syntax:

TOP (expression) [PERCENT]

[ WITH TIES ]

]

expression

Is the numeric expression that specifies the number of rows to be returned. expression is implicitly converted to a float value if PERCENT is specified; otherwise, it is converted to bigint.

PERCENT

Indicates that the query returns only the first expression percent of rows from the result set. Fractional values are rounded up to the next integer value.

References: https://docs.microsoft.com/en-us/sql/t-sql/queries/top-transact-sql?view=sql-server­2017

Question #15

CORRECT TEXT

You plan to deploy a stored procedure for a database named TICKETS.

You need to implement error handling for the stored procedure to ensure that the system-defined error messages are returned if an error occurs upon insert. Part of the correct Transact-SQL has been provided in the answer are below. Enter the code in the answer area that resolves the problem and meets the stated goals or requirements.

You can add code within the code that has been provided as well as below it.

Use the ‘Check Syntax’ button to verify your work. Any syntax or spelling errors will be reported by line and character position.

Reveal Solution Hide Solution

Correct Answer: Please review the explanation part for this answer

Explanation:

1 CREATE PROCEDURE AdCase

2 @CustomerId INT,

3 @ProblemId INT,

4 @Comment NVARCHAR (MAX)

5 AS

6

7 BEGIN TRY

8 INSERT INTO Cases

9 (CustomerId, ProblemId, Comment)

10 VALUES

11 (@CustomerId, @ProblemId, @Comment)

12 END TRY

13 BEGIN CATCH

14 INSERT INTO AppLog

15 (CurrentTime, ErrorNumber, CustomerId)

16 VALUES

17 (getdate(), ERROR_NUMBER(), @CustomerId);

18 THROW;

19

20 END CATCH

21

Make changes and additions in the above lines.

7 BEGIN TRY

12 END TRY

13 BEGIN CATCH

18 THROW;

20 END CATCH

References:

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/try-catch-transact-sql?view=sqlserver-2017

https://docs.microsoft.com/en-us/sql/t-sql/language-elements/throw-transact-sql?view=sql-server-2017

Question #16

Note: This question is part of a series of questions that use the same set of answer choices. An answer choice may be correct for more than one question in the series.

You develop a database for a travel application. You create a view that displays details of events and

attractions. The names of the event and attractions are sorted alphabetically.

You need to sort the names in a case-sensitive, dictionary order.

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.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

This topic describes SQL Server 2008 collation options for instances of SQL Server that require compatibility with versions of SQL Server that do not use collations.

The following SQL collations are listed on the Collation Settings page of the SQL Server Installation Wizard.

References: https://msdn.microsoft.com/it-it/library/ms144250(v=sql.105).aspx


Question #17

Note: This question is part of a series of questions that use the same set of answer choices. An

answer choice may be correct for more than one question in the series.

You develop a database for a travel application. You need to design tables and other database objects.

You create the Historical_Events table.

You need to store dates by using the smallest possible storage size.

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.

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The size of a column with the DATE format is 3 bytes fixed.

Question #18

DRAG DROP

You develop a Microsoft SQL Server Database.

The database contains a table named Status that is defined by the following Transact-SQL statement:

There are thousands of rows in the Status table, with significant duplication of data in the Color column. Ninety percent of the rows in the table have Color="Red", and the remaining 10 percent have Color="Green".

You want to normalize the Color information in this table.

You create a table named Colors that is defined by the following DDL:

You populate the new Colors table by using the following Transact-SQL statement:

INSERT Colors (ColorName) SELECT DISTINCT Color FROM Status

You need to ensure that the following requirements are met:

– The Status table uses only colors that exist in the Colors table.

– Data redundancy in the Status table is reduced.

– Data integrity is enforced during the normalization process.

Which three Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segment from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

First update the new column ColorID, and drop the old Column Color.

Add a check constraint on the new ColorID column, and finally add a foreign key constraint.


Question #19

DRAG DROP

You use Microsoft SQL Server client tool to develop a Microsoft Azure SQL Database instance to support an e-commerce application.

The database consists of a Product table, a Store table, and a StoreProduct table as shown in the exhibit. (Click the Exhibit button.)

You need to write a trigger that meets the following requirements:

– Stores are not physically deleted, but are marked as deleted.

– When a store is deleted, the products that are sold in that store are marked as discontinued.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Exhibit

Reveal Solution Hide Solution

Correct Answer:


Question #20

HOTSPOT

You have a database that contains the following related tables:

You create a view named OrderSummary by using the following Transact-SQL statement: For each of the following statements, select Yes if the statement is true. Otherwise, select No.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

The SalesOrderID column is used in a join statement and cannot be updated. The Status column is used can be updated. The SubTotal column is an aggregate column and cannot be updated.


Question #21

You use a Microsoft Azure SQL DataBase instance. The instance contains a table named Customers that has columns named Id, Name, and IsPriority.

You need to create a view named VwPriorityCustomers that:

– returns rows from Customer that have a value of True in the IsPriority column, and

– does not allow columns to be altered or dropped in the underlying table.

Which Transact-SQL statement shoul you run?

  • A . CREATE VIEW VwPriorityCustomers
    AS
    SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
    WITH CHECK OPTION
  • B . CREATE VIEW VwPriorityCustomers
    WITH VIEW_METADATA
    AS
    SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
  • C . CREATE VIEW VwPriorityCustomers
    WITH ENCRYPTION
    AS
    SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1
  • D . CREATE VIEW VwPriorityCustomers
    WITH SCHEMABINDING
    AS
    SELECT Id, Name FROM dbo.Customers WHERE IsPriority=1

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

SCHEMABINDING binds the view to the schema of the underlying table or tables. When SCHEMABINDING is specified, the base table or tables cannot be modified in a way that would affect the view definition.

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-view-transact­sql?view=sql-server-2017

Question #22

DRAG DROP

You use a Microsoft Azure SQL Database instance named ContosoDb. ContosoDb contains a table named Customers that has existing records.

The Customers table has columns named Id and Name.

You need to create a new column in the Customer table named Status that allows null values and sets the value of the Status column to Silver for all existing records.

Which three Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the anwer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

NULL or NOT NULL specifies whether the column can accept null values. Columns that do not allow null values can be added with ALTER TABLE only if they have a default specified or if the table is empty. NOT NULL can be specified for computed columns only if PERSISTED is also specified. If the new column allows null values and no default is specified, the new column contains a null value for each row in the table. If the new column allows null values and a default definition is added with the new column, WITH VALUES can be used to store the default value in the new column for each existing row in the table.

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/alter-table-transact­sql?view=sql-server-2017


Question #23

You administer a Microsoft SQL Server instance that will support several databases.

You need to ensure that every new database created has a data type named postalcode that contains the

same attributes.

What should you do?

  • A . Create a user-defined type on the model database.
  • B . Create a user-defined type on the master database.
  • C . Create a user-defined data type on the master database.
  • D . Create a user-defined data type on the model database.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

One option is to create SQL Server user defined data types. One trick with new databases is to create the objects in the model database, so as new databases are created the user defined data types will automatically be available.

References: https://www.mssqltips.com/sqlservertip/1628/sql-server-user-defined-data-types­rules-and-defaults/

Question #24

DRAG DROP

You administer a SQL Server database that tracks sales that are made by sales persons.

The database contains a table that is defined by the following Transact-SQL statements:

You have the following requirements:

– accept a datetime value for the query month

– return a list of salespeople IDs who have sales in the query month or before the query month

– compare sales with sales quota for salespeople who have a sales quota

– display year-to-date sales for salespeople that do not have a sales quota

How should you complete the stored procedure? To answer, drag the appropriate Transact-SQL segments to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: IIF ..

The IIF logical function returns one of two values, depending on whether the Boolean expression evaluates to true or false in SQL Server.

Syntax: IIF ( boolean_expression, true_value, false_value )

Box 2: [LastSzale] < EOMONTH(@queryMonth)

The EOMONTH function returns the last day of the month containing a specified date, with an optional offset.

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/logical-functions-iif-transact-sql?view=sql­server-2017 https://docs.microsoft.com/en-us/sql/t-sql/functions/eomonth-transact-sql?view=sql-server-2017


Question #25

DRAG DROP

You are creating queries for a shopping cart application.

You have the following requirements:

– Query1 must list products where less than 100 units have been sold in total.

– Query2 must list products where more than 10 units have been sold in a single order.

You need to identify the correct sub-queries to complete the outer queries that you have written.

Which Transact-SQL statement or statements should you use? To answer, drag the appropriate SQL statements to the correct locations. Each SQL statement may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:


Question #26

You are working with a table that has an XML column that contains information about books. Each book may have an associated price. You need to write a query that returns each author on a separate row in XML format.

Which XML method should you use?

  • A . Value()
  • B . Nodes()
  • C . Query()
  • D . Exist()

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The nodes() method is useful when you want to shred an xml data type instance into relational data. It allows you to identify nodes that will be mapped into a new row.

The result of the nodes() method is a rowset that contains logical copies of the original XML instances. In these logical copies, the context node of every row instance is set to one of the nodes identified with the query expression, so that subsequent queries can navigate relative to these context nodes.

Question #27

DRAG DROP

A database contains tables as shown in the exhibit. (Click the Exhibit button.)

Customer who are inactive are moved from the Customers table to the InactiveCustomers table. Any orders for inactive customers are removed from the Orders table.

You write the following SELECT statement to return all the inactive customers:

SELECT CustomerId FROM InactiveCustomers

You need to extend the SELECT statement to include customers who do not have any orders.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

EXCEPT returns distinct rows from the left input query that aren’t output by the right input query.

References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/set-operators-except­and-intersect-transact-sql?view=sql-server-2017


Question #28

You develop a Microsoft SQL Server database.

The database contains a table defined by the following Transact-SQL statement:

All regions have more than one employee.

You need to write a query to find the employee with the highest SalesYTD in each region with the following result set:

– First Name

– Last Name

– Region

– Sales YTD

Which Transact-SQL query should you run?

A)

B)

C)

D)

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Use TOP 1 and RANK () OVER (PARTITION BY).

References: https://docs.microsoft.com/en-us/sql/t-sql/functions/rank-transact-sql?view=sql­server-2017

Question #29

You administer a Microsoft SQL Server database that contains a table named Products.

In a bit column named Discontinued, a value of 1 indicates a product is inactive, and a value of 0

indicates the product is active.

You need to create a view that returns a column with a full product status description.

Which expression should you use to define the column?

  • A . IF(Discontinued = 0, ‘Active’, ‘Inactive’)
  • B . CASE Discontinued
    WHEN 0 THEN ‘Active’
    WHEN 1 THEN ‘Inactive’
    END
  • C . IF Discontinued = 0
    ‘ Active’
    ELSE
    ‘ Inactive’
  • D . DECODE (Discontinued, 0, ‘Active’, 1, ‘Inactive’, ‘Unknown’)

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

The CASE statement evaluates a list of conditions and returns one of multiple possible result expressions.

The CASE expression has two formats:

The simple CASE expression compares an expression to a set of simple expressions to determine the result.

The searched CASE expression evaluates a set of Boolean expressions to determine the result.

Both formats support an optional ELSE argument.

CASE can be used in any statement or clause that allows a valid expression.

References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/case-transact­sql?view=sql-server-2017

Question #30

DRAG DROP

You develop a Microsoft SQL Server database that supports an e-commerce website.

You create a table defined by the following Transact-SQL statement:

You need to create a reusable function that will remove all carriage return characters from all the text values.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

References: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-function-transact­sql?view=sql-server-2017


Question #31

You administer a Microsoft SQL Server database named Orders. Orders is highly active OLTP system used for e-commerce.

Performance on the database has degraded over the past few months as the volume of data has increased, and now users report the application is unusable.

You need to identify the cause of the performance problem.

Which Transact-SQL statement should you run?

  • A . SET STATISTICS TIME ON
  • B . SET FORCEPLAN ON
  • C . SET STATISTICS IO ON
  • D . DBCC CHECKCONTRAINTS

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

When FORCEPLAN is set to ON, the SQL Server query optimizer processes a join in the same order as the tables appear in the FROM clause of a query. In addition, setting FORCEPLAN to ON forces the use of a nested loop join unless other types of joins are required to construct a plan for the query, or they are requested with join hints or query hints.

Question #32

DRAG DROP

You need to create a cursor that meets the following requirements:

– Executes as quickly as possible.

– Reflects all data changes made to the table while scrolling.

Which five Transact-SQL statements should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer are and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Step 1: Declare variables.

Step 2: Open the cursor

Step 3: Fetch the first instance.

Step 4: Loop

Step 5: Close and deallocate the cursor References: https://docs.microsoft.com/en-us/sql/t-sql/language-elements/declare-cursor-transact­

sql?view=sql-server-2017


Question #33

DRAG DROP

You administer a Microsoft Azure SQL Database instance.

You are troubleshooting a number of stored procedures that use transactions.

-p_ModifyCustomer modifies customer records in the database. Processes that uses these records must receive a copy of the record as it exists at the beginning of the transaction, and the procedure must not block these processes.

-p_GetOrders is used to retrieve orders for a customer. While the transaction is running, no other process should be able to read the same data, and no other transaction should be able to modify the data until the transaction completes.

-p_ShipOrders is run once per day to batch orders into shipping criteria. While this transaction is running, no other transaction should be allowed to insert data into the range of orders being modified.

You need to choose the appropriate transaction isolation level for each stored procedure. The transaction must meet the need while providing the highest level of concurrency and performance.

Which isolation levels should you use? To answer, drag the appropriate isolation levels to correct stored procedures. Each isolation level may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:

Explanation:

Box 1: READ_COMMITTED

READ COMMITTED specifies that statements cannot read data that has been modified but not committed by other transactions. This prevents dirty reads. Data can be changed by other transactions between individual statements within the current transaction, resulting in nonrepeatable reads or phantom data. This option is the SQL Server default.

The behavior of READ COMMITTED depends on the setting of the READ_COMMITTED_SNAPSHOT database option

Box 2: REPEATABLE_READ:

REPEATABLE_READ specifies that statements cannot read data that has been modified but not yet committed by other transactions and that no other transactions can modify data that has been read by the current transaction until the current transaction completes.

Shared locks are placed on all data read by each statement in the transaction and are held until the transaction completes. This prevents other transactions from modifying any rows that have been read by the current transaction.

Box 3: SERIALIZABLE

SERIALIZABLE Specifies the following:

Statements cannot read data that has been modified but not yet committed by other transactions. No other transactions can modify data that has been read by the current transaction until the current transaction completes. Other transactions cannot insert new rows with key values that would fall in the range of keys read by any statements in the current transaction until the current transaction completes.

Reference: https://docs.microsoft.com/en-us/sql/t-sql/statements/set-transaction-isolation-level­transact-sql?view=sql-server-2017


Question #34

DRAG DROP

You administer a Microsoft SQL Server database that contains a table named Customer defined by the following Transact-SQL statement:

The SalesRep column contains the SQL Login name of the user designated as the customer’s sales rep.

You need to create at trigger that meets the following requirements:

– A customer’s CreditLimit can only be changed by the customer’s SalesRep.

– CreditLimit cannot be increased by more than 50 percent in any single update.

If an UPDATE statement causes either of these business rules to be violated, the entire UPDATE statement should be rolled back.

In addition, the trigger must handle single-row and multi-row update statements and should execute in the most efficient manner possible.

How should you complete the trigger? To answer, drag the appropriate Transact-SQL segments to the correct locations. Each Transact-SQL segment may be used once, more than once, or not at all. You may need to drag the split bar between panes or scroll to view content.

Reveal Solution Hide Solution

Correct Answer:


Question #35

You develop a Microsoft SQL Server database that contains tables as shown in the exhibit. (Click the Exhibit button.)

You need to retrieve a list of clients for whom there is no corresponding information in the Projects table.

Which Transact-SQL statements should you run?

A)

B)

C)

D)

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

References: https://www.dofactory.com/sql/select-distinct https://www.dofactory.com/sql/right-outer-join

Question #36

Note: This question is part of series of questions that use the same or similar answer choices. An answer choice may be correct for more than one question in the series. Each question is independent of the other questions in the series. Information and details provided in a question apply only to that question.

You administer a Microsoft SQL Server database.

The database contains a table named Employee.

Part of the Employee table is shown in the exhibit. (Click the Exhibit button.)

Unless stated above, no columns in the Employee table reference other tables.

Confidential information about the employees is stored in a separate table named EmployeeData.

One record exists within EmployeeData for each record in the Employee table.

You need to assign the appropriate constraints and table properties to ensure data integrity and

visibility.

Which column in the Employee table should be referenced in a one-to-one relationship by the EmployeeData table?

  • A . DateHired
  • B . DepartmentID
  • C . EmployeeID
  • D . EmployeeNum
  • E . FirstName
  • F . JobTitle
  • G . LastName
  • H . MiddleName
  • I . ReportsToID

Reveal Solution Hide Solution

Correct Answer: C
Question #37

You use a Microsoft SQL Server database.

You want to create a table to store files.

You need to ensure that the following requirements are met:

– The files must include information about the directory structure.

– The files must be accessible in SQL Server.

– The files must be in a folder that is accessible directly by using Windows Explorer.

Which Transact-SQL statement should you run?

A)

B)

C)

D)

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

References: https://docs.microsoft.com/en-us/sql/relational-databases/blob/create-alter-and-drop­filetables?view=sql-server-2017

Question #38

DRAG DROP

You administer a Microsoft SQL Server database named ContosoDb. ContosoDb contains a table named Suppliers and an indexed view named VWLocalSuppliers, both of which were created by using the following Transact-SQL statement: You need to change the data type of the Code column in the Suppliers table to nvarchar(50).

Which four Transact-SQL segments should you use to develop the solution? To answer, move the appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:


Question #39

You develop a Microsoft SQL Server database named ContosoDb. ContosoDb contains a table named Employess that was created by using the following Transact-SQL statement:

You need to create a view that allows the insertion of new records into the Employees table by using the view.

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: C
Question #40

The Agent table of a Microsoft SQL Server database contains several million rows. The database uses the SQL_Latin1_General_Cp1_CS_AS collation.

You need to ensure that the following requirements are met:

– The values of the StateRefID column conform to the pattern of 3 uppercase letters followed by 5 numeric digits, such as “ABC12345”.

– The StateRefID values are unique within the Agent table.

– The values of all records that will be inserted or updated in the Agent table are correctly formatted.

– Exisitng rows are ignored

Which Transact-SQL statement should you run?

  • A . Option A
  • B . Option B
  • C . Option C
  • D . Option D

Reveal Solution Hide Solution

Correct Answer: A

Question #41

DRAG DROP

You are a Microsoft SQL Server client tools to develop a Microsoft Azure SQL Database database that supports an e-learning application.

The database consists of a Course table, a Subject table, and a CourseSubject table as shown in the exhibit. (Click the Exhibit button.)

You need to write a trigger that meets the following requirements: Subjects are not physically deleted, but are marked as deleted. When a subject is deleted, the courses that offer that subject are marked as discontinued.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the

appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area

and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:


Question #42

DRAG DROP

A database contains tables as shown in the exhibit. (Click the Exhibit button.)

Products that are discontinued are moved from the Products table to the DiscontinuedProducts table. Any orders for discontinued products are removed from the Orders table. You write the following SELECT statement to return all the discontinued products: SELECT ProductId FROM DiscontinuedProducts You need to extend the SELECT statement to include products who do not have any orders.

Which four Transact-SQL segments should you use to develop the solution? To answer, move the

appropriate Transact-SQL segments from the list of Transact-SQL segments to the answer area and arrange them in the correct order.

Reveal Solution Hide Solution

Correct Answer:


Question #43

You are working with a table that has an XML column that contains information about books. Each

book may have an associated price.

You need to write with a query that returns the price of each book as a non-xml value.

Which XML method should you use?

  • A . Exist()
  • B . Nodes()
  • C . Query()
  • D . Value()

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

References: https://docs.microsoft.com/en-us/sql/t-sql/xml/nodes-method-xml-data­type?view=sql-server-2017

Question #44

You develop a Microsoft SQL Server 2012 server database that supports an application. The application contains a table that has the following definition:

CREATE TABLE Inventory

(ItemID int NOT NULL PRIMARY KEY,

ItemsInStore int NOT NULL,

ItemsInWarehouse int NOT NULL)

You need to create a computed column that returns the sum total of the ItemsInStore and ItemsInWarehouse values for each row.

Which Transact-SQL statement should you use?

  • A . ALTER TABLE Inventory
    ADD TotalItems AS ItemsInStore + ItemsInWarehouse
  • B . ALTER TABLE Inventory
    ADD ItemsInStore – ItemsInWarehouse = TotalItemss
  • C . ALTER TABLE Inventory
    ADD TotalItems = ItemsInStore + ItemsInWarehouse
  • D . ALTER TABLE Inventory
    ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse);

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

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

Question #45

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.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

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

Question #46

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 with time zone information.

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.

Reveal Solution Hide Solution

Correct Answer: I
I

Explanation:

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

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

Question #47

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 with multiple event names and their dates as parameters.

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.

Reveal Solution Hide Solution

Correct Answer: E
Question #48

CORRECT TEXT

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

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

• Accept the @T integer parameter.

• Use one-part names to reference columns.

• Filter the query results by SalesTerritoryID.

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

Which code segment should you use? To answer, type the correct code in the answer area.

Reveal Solution Hide Solution

Correct Answer: CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)

RETURNS TABLE

AS

RETURN

(

SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue

FROM Sales.OrdersByTerritory

WHERE SalesTerritoryID = @T

)

Question #49

CORRECT TEXT

You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)

You deploy a new server that has SQL Server 2012 installed.

You need to create a table named Sales.OrderDetails on the new server. Sales.OrderDetails must meet the following requirements:

• Write the results to a disk.

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

• The code must NOT use any object delimiters.

The solution must ensure that LineItemTotal is stored as the last column in the table.

Which code segment should you use? To answer, type the correct code in the answer area.

Reveal Solution Hide Solution

Correct Answer: CREATE TABLE Sales.OrderDetails (

ListPrice money not null,

Quantity int not null,

LineItemTotal as (ListPrice * Quantity) PERSISTED)

Explanation:

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

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

Question #50

CORRECT TEXT

You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)

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

• The code must NOT include object delimiters.

• The view must be created in the Sales schema.

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

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

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

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

Which code segment should you use? To answer, type the correct code in the answer area.

Reveal Solution Hide Solution

Correct Answer: CREATE VIEW Sales.uv_CustomerFullName

WITH SCHEMABINDING

AS

SELECT FirstName, LastName

FROM Sales.Customers

Explanation:

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

Question #51

CORRECT TEXT

You have a database that contains the tables shown in the exhibit. (Click the Exhibit button.)

You need to create a query that calculates the total sales of each OrderId from the Sales.Details table.

The solution must meet the following requirements:

• Use one-part names to reference columns.

• Sort the order of the results from OrderId.

• NOT depend on the default schema of a user.

• Use an alias of TotalSales for the calculated ExtendedAmount.

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

Which code segment should you use? To answer, type the correct code in the answer area.

Reveal Solution Hide Solution

Correct Answer: SELECT OrderID, SUM(ExtendedAmount) AS TotalSales

FROM Sales.Details

GROUP BY OrderID

ORDER BY OrderID

Question #52

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

• Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.

• Results must include customers who have not placed any orders.

Which Transact-SQL query should you use?

  • A . SELECT CustomerName, OrderDate
    FROM Customers
    RIGHT OUTER JOIN Orders
    ON Customers.CustomerID = Orders.CustomerID
  • B . SELECT CustomerName, OrderDate
    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

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

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

Question #53

You create a stored procedure that will update multiple tables within a transaction.

You need to ensure that if the stored procedure raises a run-time error, the entire transaction is terminated and rolled back.

Which 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

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

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

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

Question #54

Your database contains two tables named DomesticSalesOrders and InternationalSalesOrders. Both tables contain more than 100 million rows. Each table has a Primary Key column named SalesOrderId. The data in the two tables is distinct from one another.

Business users want 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.

Which 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

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

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-optimalperformance-comparison/

Question #55

You are a database developer at an independent software vendor. You create stored procedures that contain proprietary code.

You need to protect the code from being viewed by your customers.

Which stored procedure option should you use?

  • A . ENCRYPTBYKEY
  • B . ENCRYPTION
  • C . ENCRYPTBYPASSPHRASE
  • D . ENCRYPTBYCERT

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

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

Question #56

You use a Microsoft SQL Server 2012 database.

You want to create a table to store Microsoft Word documents.

You need to ensure that the documents must only be accessible via Transact-SQL queries.

Which 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] ROWGUIDCOL NOT NULL UNIQUE,
    [Document] VARBINARY(MAX) FILESTREAM NULL
    )
    GO

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

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

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

Question #57

You administer a Microsoft SQL Server 2012 database that 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 without taking the index offline.

Which Transact-SQL batch should you use?

  • A . CREATE INDEX NCI_OrderDetail_CustomerID ON OrderDetail.CustomerID WITH 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

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

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

Question #58

You develop a Microsoft SQL Server 2012 database. The database is used by two web applications that access a table named Products.

You want to create an object that will prevent the applications from accessing the table directly while still providing access to the required data.

You need to ensure that the following requirements are met:

– Future modifications to the table definition will 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.

What should you create for each application?

  • A . views
  • B . table partitions
  • C . table-valued functions
  • D . stored procedures

Reveal Solution Hide Solution

Correct Answer: A
Question #59

You develop a Microsoft SQL Server 2012 database.

You need to create a batch process that meets the following requirements: -Returns a result set based on supplied parameters. -Enables the returned result set to perform a join with a table.

Which object should you use?

  • A . Inline user-defined function
  • B . Stored procedure
  • C . Table-valued user-defined function
  • D . Scalar user-defined function

Reveal Solution Hide Solution

Correct Answer: C
Question #60

You develop a Microsoft SQL Server 2012 database.

You need to create and call a stored procedure that meets the following requirements:

– Accepts a single input parameter for CustomerID.

– Returns a single integer to the calling application.

Which Transact-SQL statement or statements should you use? (Each correct answer presents part of the solution. Choose all that apply.)

  • A . CREATE PROCEDURE dbo.GetCustomerRating
    @CustomerID 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,
    @CustomerRatingByCustomer
  • D . CREATE PROCEDURE dbo.GetCustomerRating
    @CustomerID INT,
    @CustomerRating INT OUTPUT
    AS
    SET NOCOUNT ON
    SELECT @Result = CustomerOrders/CustomerValue
    FROM Customers
    WHERE CustomerID = @CustomerID
    RETURN @Result
    GO
  • E . DECLARE @CustomerRatingByCustomer 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
    WHERE CustomerID = @CustomerID
    RETURNS @Result
    GO

Reveal Solution Hide Solution

Correct Answer: A,E

Question #61

You develop a Microsoft SQL Server 2012 database that contains a heap named OrdersHistorical.

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

Reveal Solution Hide Solution

Correct Answer: E
E

Explanation:

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

Question #62

You use a Microsoft SQL Server 2012 database that contains two tables named SalesOrderHeader and SalesOrderDetail.

The indexes on the tables are as shown in the exhibit. (Click the Exhibit button.)

You write the following Transact-SQL query:

You discover that the performance of the query is slow. Analysis of the query plan shows table scans where the estimated rows do not match the actual rows for SalesOrderHeader by using an unexpected index on SalesOrderDetail.

You need to improve the performance of the query.

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

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

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

Question #63

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

Reveal Solution Hide Solution

Correct Answer: D
D

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

Question #64

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.

Reveal Solution Hide Solution

Correct Answer: F
F

Explanation:

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

Question #65

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.

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

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

Question #66

You are a database developer of a Microsoft SQL Server 2012 database.

You are designing a table that will store Customer data from different sources. The table will 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 shown in the following table.

You need to ensure that the table has no duplicate CustomerID within a SourceID. You also need to ensure that the data in the table is in the order of SourceID and then CustomerID.

Which 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));

Reveal Solution Hide Solution

Correct Answer: D
Question #67

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.

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

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

Question #68

You develop a Microsoft SQL Server 2012 database that contains tables named Employee and Person.

The tables have the following definitions:

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

Reveal Solution Hide Solution

Correct Answer: B
Question #69

You develop a Microsoft SQL Server 2012 database that contains a table named Products.

The Products table has the following definition:

You need to create an audit record only when either the RetailPrice or WholeSalePrice column is updated.

Which Transact-SQL query should you use?

  • A . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
    IF CCLUMNS_CHANGED(RetailPrice, WholesalePrice)
    – – Create Audit Records
  • B . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
    IF EXISTS(SELECT RetailPrice from inserted) OR
    EXISTS (SELECT WholeSalePnce FROM inserted)
    – – Create Audit Records
  • C . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
    IF COLUMNS_UPDATED(RetailPrice, WholesalePrice)
    – – Create Audit Records
  • D . CREATE TRIGGER TrgPriceChange ON Products FOR UPDATE AS
    IF UPDATE(RetailPrice) OR UPDATE(WholeSalePrice)
    – – Create Audit Records

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

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

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

Question #70

A table named Profits stores the total profit made each year within a territory. The Profits table has columns 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.

Which 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

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

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

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

Question #71

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.

Which Transact-SQL operator should you use?

  • A . CROSS JOIN
  • B . CROSS APPLY
  • C . PIVOT
  • D . UNPIVOT

Reveal Solution Hide Solution

Correct Answer: C
C

Explanation:

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

Question #72

You administer a Microsoft SQL Server database that supports a shopping application.

You need to retrieve a list of customers who live in territories that do not have a sales person.

Which Transact- SQL query or queries should you use? (Each correct answer presents a complete solution. Choose all that apply.)

  • A . SELECT CustomerID FROM Customer
    WHERE TerritoryID <> SOME(SELECT TerritoryID FROM Salesperson)
  • B . SELECT CustomerID FROM Customer
    WHERE TerritoryID <> ALL(SELECT TerritoryID FROM Salesperson)
  • C . SELECT CustomerID FROM Customer
    WHERE TerritoryID <> ANY(SELECT TerritoryID FROM Salesperson)
  • D . SELECT CustomerID FROM Customer
    WHERE TerritoryID NOT IN(SELECT TerritoryID FROM Salesperson)

Reveal Solution Hide Solution

Correct Answer: B,D
Question #73

You support a database structure shown in the exhibit. (Click the Exhibit button.)

You need to write a query that displays the following details:

• Total sales made by sales people, year, city, and country

• Sub totals only at the city level and country level

• A grand total of the sales amount

Which Transact-SQL query should you use?

  • 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)

Reveal Solution Hide Solution

Correct Answer: A
A

Explanation:

Be careful with this question, because on exam can be different options for answer.

And none of them is correct: D You should report this question.

Reference: http://www.grapefruitmoon.net/diving-into-t-sql-grouping-sets/

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

Question #74

You are developing a database that will contain price information.

You need to store the prices that include a fixed precision and a scale of six digits.

Which data type should you use?

  • A . Float
  • B . Money
  • C . Smallmoney
  • D . Numeric

Reveal Solution Hide Solution

Correct Answer: D
D

Explanation:

Numeric is the only one in the list that can give a fixed precision and scale. Reference: http://msdn.microsoft.com/en-us/library/ms179882.aspx

Question #75

You administer a Microsoft SQL Server database that supports a banking transaction management application.

You need to retrieve a list of account holders who live in cities that do not have a branch location.

Which Transact-SQL query or queries should you use? (Each correct answer presents a complete solution. Choose all that apply.)

  • A . SELECT AccountHolderID
    FROM AccountHolder
    WHERE CityID NOT IN (SELECT CityID FROM BranchMaster)
  • B . SELECT AccountHolderID
    FROM AccountHolder
    WHERE CityID <> ALL (SELECT CityID FROM BranchMaster)
  • C . SELECT AccountHolderID
    FROM AccountHolder
    WHERE CityID <> SOME (SELECT CityID FROM BranchMaster)
  • D . SELECT AccountHolderID
    FROM AccountHolder
    WHERE CityID <> ANY (SELECT CityID FROM BranchMaster)

Reveal Solution Hide Solution

Correct Answer: A,B
A,B

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

Question #76

You administer a Microsoft SQL Server 2012 database. The database contains a table named Employee.

Part of the Employee table is shown in the exhibit. (Click the Exhibit button.)

Confidential information about the employees is stored in a separate table named EmployeeData. One record exists within EmployeeData for each record in the Employee table. You need to assign the appropriate constraints and table properties to ensure data integrity and visibility.

On which column in the Employee table should you create a unique constraint?

  • A . DateHired
  • B . DepartmentID
  • C . EmployeeID
  • D . EmployeeNum
  • E . FirstName
  • F . JobTitle
  • G . LastName
  • H . MiddleName
  • I . ReportsToID

Reveal Solution Hide Solution

Correct Answer: D
Question #77

You administer a Microsoft SQL Server 2012 database. The database contains a table named Employee.

Part of the Employee table is shown in the exhibit. (Click the Exhibit button.)

Unless stated above, no columns in the Employee table reference other tables.

Confidential information about the employees is stored in a separate table named EmployeeData. One record exists within EmployeeData for each record in the Employee table.

You need to assign the appropriate constraints and table properties to ensure data integrity and visibility.

On which column in the Employee table should you use an identity specification to include a seed of 1,000 and an increment of 1?

  • A . DateHired
  • B . DepartmentID
  • C . EmployeeID
  • D . EmployeeNum
  • E . FirstName
  • F . JobTitle
  • G . LastName
  • H . MiddleName
  • I . ReportsToID

Reveal Solution Hide Solution

Correct Answer: C
Question #78

You administer a Microsoft SQL Server 2012 database that includes a table named Products. The Products table has columns named ProductId, ProductName, and CreatedDateTime.

The table contains a unique constraint on the combination of ProductName and CreatedDateTime.

You need to modify the Products table to meet the following requirements:

-Remove all duplicates of the Products table based on the ProductName column. -Retain only the newest Products row.

Which Transact-SQL query should you use?

  • A . WITH CTEDupRecords
    AS
    (
    SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
    FROM Products
    GROUP BY ProductName
    HAVING COUNT(*) > 1
    )
    DELETE p
    FROM Products p
    JOIN CTEDupRecords cte ON
  • B . ProductName = cte.ProductName
    AND p.CreatedDateTime > cte.CreatedDateTime
  • C . 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
  • D . WITH CTEDupRecords
    AS
    (
    SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName
    FROM Products
    GROUP BY ProductName
    )
    DELETE p
    FROM Products p
    JOIN CTEDupRecords cte ON
  • E . ProductName = cte.ProductName
  • F . 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
  • G . ProductName = cte.ProductName

Reveal Solution Hide Solution

Correct Answer: B
Question #79

You develop three Microsoft SQL Server 2012 databases named Database1, Database2, and Database3. You have permissions on both Database1 and Database2.

You plan to write and deploy a stored procedure named dbo.usp_InsertEvent in Database3. dbo.usp_InsertEvent must execute other stored procedures in the other databases.

You need to ensure that callers that do not have permissions on Database1 or Database2 can execute the stored procedure.

Which Transact-SQL statement should you use?

  • A . USE Database2
  • B . EXECUTE AS OWNER
  • C . USE Database1
  • D . EXECUTE AS CALLER

Reveal Solution Hide Solution

Correct Answer: B
B

Explanation:

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

Reference: http://blog.sqlauthority.com/2007/10/06/sql-server-executing-remote-stored-procedure­callingstored-procedure-on-linked-server/

Question #80

You administer a Microsoft SQL Server 2012 database that 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 who are prevented from deleting records in the Sales schema.

You need to achieve this goal by using the minimum amount of administrative effort.

What 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 owned schema for the db_denydatawriter role. Add the users to the db_denydatawriter 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.

Reveal Solution Hide Solution

Correct Answer: A
Exit mobile version