70-457 140 Q&S Transition Your MCTS on SQL Server 2008 to MCSA: SQL Server 2012, Part 1

Which three actions should you perform in sequence?

You administer three Microsoft SQL Server 2012 servers named ServerA, ServerB, and ServerC. ServerA is the acting principal and ServerB is the mirror. You need to add ServerC as a witness to the existing mirroring session between ServerA and ServerB. You need to achieve this goal without delaying synchronization. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four Transact-SQL statements should you use?

You administer a Microsoft SQL Server 2012 database. You use an OrderDetail table that has the following definition:

You need to create a non-clustered index on the SalesOrderID column in the OrderDetail table to include only rows that contain a value in the SpecialOfferID column. Which four Transact-SQL statements should you use? (To answer, move the appropriate statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four Transact-SQL statements should you use?

You want to add a new GUID column named BookGUID to a table named dbo.Book that already contains data. BookGUID will have a constraint to ensure that it always has a value when new rows are inserted into dbo.Book. You need to ensure that the new column is assigned a GUID for existing rows. Which four Transact-SQL statements should you use? (To answer, move the appropriate SQL statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer two Microsoft SQL Server 2012 servers named ServerA and ServerB. You use a database named AdventureWorks. You need to prepare the AdventureWorks database for database mirroring. ServerB will act as the mirror in a mirroring partnership along with ServerA. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which six actions should you perform in sequence?

You administer three Microsoft SQL Server 2008 R2 instances. Database mirroring is configured in High-Safety mode with Automatic Failover between the following three servers:
• SQL1 is the Principal server.
• SQL2 is the mirror server.
• SQL3 is the witness server.
You need to upgrade SQL1 and SQL2 to SQL Server 2012. You need to ensure that downtime is minimized during the upgrade. Which six actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 server that has multiple databases. You need to ensure that users are unable to create stored procedures that begin with sp_. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which tool or tools should you use?

DRAG AND DROP
You administer a Microsoft SQL Server 2012 server. A variety of issues occur from time to time in the production environment. You need to identify the appropriate tool for each issue. Which tool or tools should you use? (To answer, drag the appropriate tool or tools to the correct issue or issues in the answer area. Each tool 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.)
Select and Place:



Answer Clike
Which three actions should you perform in sequence?

You administer a single Microsoft SQL Server instance on a two-node failover cluster that has nodes named Node A and Node B. The instance is currently running on Node A. You want to patch both Node A and Node B by using the most recent SQL Server Service Pack. You need to ensure that the following requirements are met:
• Both nodes receive the update.
• Downtime is minimized.
• No data is lost.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four Transact-SQL statements should you use?

You develop a database application for a university. You need to create a view that will be indexed that meets the following requirements:
• Displays the details of only students from Canada.
• Allows insertion of details of only students from Canada.
Which four Transact-SQL statements should you use? (To answer, move the appropriate SQL statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four Transact-SQL statements should you insert at line 07?

You create the following stored procedure. (Line numbers are included for reference only.)

You need to ensure that the stored procedure performs the following tasks:
• If a record exists, update the record.
• If no record exists, insert a new record.
Which four Transact-SQL statements should you insert at line 07? (To answer, move the appropriate statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three Transact-SQL statements should you use?

You use Microsoft SQL Server 2012 to develop a database application. You create a table by using the following 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. Which three Transact-SQL statements should you use? (To answer, move the appropriate SQL statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three Transact-SQL statements should you use?

You use Microsoft SQL Server 2012 to develop a database that has two tables named Div1Cust and Div2Cust. Each table has columns named DivisionID and CustomerId . None of the rows in Div1Cust exist in Div2Cust. You need to write a query that meets the following requirements:
• The rows in Div1Cust must be combined with the rows in Div2Cust.
• The result set must have columns named Division and Customer.
• Duplicates must be retained.
Which three Transact-SQL statements should you use? (To answer, move the appropriate statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
What should you do?

HOTSPOT
You administer a Microsoft SQL Server 2012 database. The database contains a table that has the following definition:

You want to export data from the table to a flat file by using the SQL Server Import and Export Wizard. You need to ensure that the following requirements are met:
• The first row of the file contains the first row of data.
• Each record is of the same length.
• The date follows the U.S. date format.
• The file supports international characters.
What should you do? (To answer, simply select the option or options in the answer area that you would configure.)
Hot Area:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 database. The database uses SQL Server Agent jobs to perform regular FULL and LOG backups. The database uses the FULL recovery model. You plan to perform a bulk import of a very large text file. You need to ensure that the following requirements are met during the bulk operation:
• The database transaction log is minimally affected.
• The database is online and all user transactions are recoverable.
• All transactions are fully recoverable prior to the import.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 instance that contains a database of confidential data. You need to encrypt the database files at the page level. You also need to encrypt the transaction log files. Which four actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 database. The database is backed up according to the following schedule:
• Daily full backup at 23:00 hours.
• Differential backups on the hour, except at 23:00 hours.
• Log backups every 10 minutes from the hour, except on the hour.
The database uses the Full recovery model. A developer accidentally drops a number of tables and stored procedures from the database between 22:40 hours and 23:10 hours. You perform a database restore at 23:30 hours to recover the dropped table. You need to restore the database by using the minimum amount of administrative effort. You also need to ensure minimal data loss. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which Transact-SQL statements should you use?

You administer a Microsoft SQL Server 2012 server that has a database named Contoso. The Contoso database has a table named EmployeeSalary in a schema named HumanResources. You need to create a script that writes audit events into the application log whenever data in the EmployeeSalary table is modified. Which Transact-SQL statements should you use? (To answer, move the appropriate statements from the list of statements to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 environment that contains a production SQL Server 2005 instance named SQL2005 and a development SQL Server 2012 instance named SQL2012. The development team develops a new application that uses the SQL Server 2012 functionality. You are planning to migrate a database from SQL2005 to SQL2012 so that the development team can test their new application. You need to migrate the database without affecting the production environment. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 database. Your database is experiencing deadlock issues. You need to be able to monitor deadlocks. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server 2012 database. All database traffic to the SQL Server must be encrypted by using secure socket layer (SSL) certificates or the connection must be refused. Network administrators have deployed server certificates to the Windows store of all Windows servers on the network from a trusted Certificate Authority. This is the only Certificate Authority allowed to distribute certificates on the network.
You enable the Force Encryption flag for the MSSQLServer protocols, but client computers are unable to connect. They receive the following error message:
"A connection was successfully established with the server, but then an error occurred during the pre-login handshake, (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.) (Microsoft SQL Server)"
You notice the following entry in the SQL Server log:
"A self-generated certificate was successfully loaded for encryption."
You need to configure SQL Server to encrypt all client traffic across the network. You also need to ensure that client computers are able to connect to the server by using a trusted certificate. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You administer a Microsoft SQL Server instance. You use a two-node SQL Server failover cluster. Node B is primary, and Node A is secondary. You need to install a security patch on both nodes. You need to ensure that the following requirements are met:
• Both nodes receive the update.
• Downtime is minimized.
• No data is lost.
Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which three actions should you perform in sequence?

You are a database administrator of a Microsoft SQL Server 2012 environment. The environment contains two servers named SQLServer01 and SQLServer02. The database Contoso exists on SQLServer01. You plan to mirror the Contoso database between SQLServer01 and SQLServer02 by using database mirroring. You need to prepare the Contoso database for database mirroring. Which three actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
Which four actions should you perform in sequence?

You administer a Microsoft SQL Server database. Service accounts for SQL Agent are configured to use a local user. A Microsoft SQL Server Integration Services (SSIS) job step has been created within a SQL Server Agent job. The SSIS package accesses a network share when exporting data from a SQL Server database. When you execute the SQL Server Agent job, it fails due to a permissions failure on a share on a remote server. You need to ensure that the SQL Server Agent job can execute the SSIS package. Which four actions should you perform in sequence? (To answer, move the appropriate actions from the list of actions to the answer area and arrange them in the correct order.)
Build List and Reorder:



Answer Clike
What should you do?

DRAG AND DROP
You administer several Microsoft SQL Server 2012 servers. Your company has a number of offices across the world connected by using a wide area network (WAN). Connections between offices vary significantly in both bandwidth and reliability. You need to identify the correct replication method for each scenario. What should you do? (To answer, drag the appropriate replication method or methods to the correct location or locations in the answer area. Each replication method may be used once, more than once, or not at all.)
Select and Place:



Answer Clike
What should you configure?

You administer a Microsoft SQL Server 2012 Enterprise Edition server that uses 64 cores. You discover performance issues when large amounts of data are written to tables under heavy system load. You need to limit the number of cores that handle I/O. What should you configure?
A. Processor affinity
B. Lightweight pooling
C. Max worker threads
D. I/O affinity


Answer Clike
Which code segment should you use?

You have an XML schema collection named Sales.InvoiceSchema. You need to declare a variable of the XML type named XML1. The solution must ensure that XML1 is validated by using Sales.InvoiceSchema.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. Declare @XML1=XML(Sales.InvoiceSchema)
B. DECLARE @XML1 XML
@XML1 = Sales.InvoiceSchema
CREATE XML SCHEMA COLLECTION XML1 AS @XML1


Answer Clike
What should you do?

You administer a single server that contains a Microsoft SQL Server 2012 default instance. You plan to install a new application that requires the deployment of a database on the server. The application login requires sysadmin permissions. You need to ensure that the application login is unable to access other production databases. What should you do?
A. Use the SQL Server default instance and configure an affinity mask.
B. Install a new named SQL Server instance on the server.
C. Use the SQL Server default instance and enable Contained Databases.
D. Install a new default SQL Server instance on the server.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 instance. After a routine shutdown, the drive that contains tempdb fails. You need to be able to start the SQL Server. What should you do?
A. Modify tempdb location in startup parameters.
B. Start SQL Server in minimal configuration mode.
C. Start SQL Server in single-user mode.
D. Configure SQL Server to bypass Windows application logging.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 database. The database contains a Product table created by using the following definition:

You need to ensure that the minimum amount of disk space is used to store the data in the Product table. What 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.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server. The MSSQLSERVER service uses a domain account named CONTOSOSQLService. You plan to configure Instant File Initialization. You need to ensure that Data File Autogrow operations use Instant File Initialization. What should you do? Choose all that apply.
A. Restart the SQL Server Agent Service.
B. Disable snapshot isolation.
C. Restart the SQL Server Service.
D. Add the CONTOSOSQLService account to the Perform Volume Maintenance Tasks local security policy.
E. Add the CONTOSOSQLService account to the Server Operators fixed server role.
F. Enable snapshot isolation.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server. One of the databases on the server supports a highly active OLTP application. Users report abnormally long wait times when they submit data into the application. You need to identify which queries are taking longer than 1 second to run over an extended period of time. What should you do?
A. Use SQL Profiler to trace all queries that are processing on the server. Filter queries that have a Duration value of more than 1,000.
B. Use sp_configure to set a value for blocked process threshold. Create an extended event session.
C. Run the sp_who command from a query window.
D. Run the DBCC TRACEON 1222 command from a query window and review the SQL Server event log.
E. Use the Job Activity monitor to review all processes that are actively running. Review the Job History to find out the duration of each step.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 database. Users report that an application that accesses the database displays an error, but the error does not provide meaningful information. No entries are found in the SQL Server log or Windows event logs related to the error. You need to identify the root cause of the issue by retrieving the error message. What should you do?
A. Create an Extended Events session by using the sqlserver.error_reported event.
B. Create a SQL Profiler session to capture all ErrorLog and EventLog events.
C. Flag all stored procedures for recompilation by using sp_recompile.
D. Execute sp_who.


Answer Clike
Which Transact-SQL query should you use?

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)


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 instance. You need to stop a blocking process that has an SPID of 64 without stopping other processes.
What should you do?
A. Execute the following Transact-SQL statement:
EXECUTE sp_KillSPID 64
B. Restart the SQL Server service.
C. Execute the following Transact-SQL statement:
KILL 64
D. Execute the following Transact-SQL statement:
ALTER SESSION KILL ’64’


Answer Clike
Which configuration should you use?

You administer all the deployments of Microsoft SQL Server 2012 in your company. You need to ensure that an OLTP database that includes up-to-theminute reporting requirements can be off-loaded from the primary database to another server. You also need to be able to add indexes to the secondary database. Which configuration should you use?
A. Two servers configured in different data centers
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
One server configured as an Active Secondary
B. Two servers configured in the same data center
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
One server configured as an Active Secondary
C. Two servers configured in the same data center
A primary server configured to perform log-shipping every 10 minutes • A backup server configured as a warm standby
D. Two servers configured in different data centers
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
E. Two servers configured on the same subnet
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
F. SQL Server that includes an application database configured to perform transactional replication
G. SQL Server that includes an application database configured to perform snapshot replication
H. Two servers configured in a Windows Failover Cluster in the same data center
SQL Server configured as a clustered instance


Answer Clike
Which configuration should you use?

You administer all the deployments of Microsoft SQL Server 2012 in your company. You need to ensure that data changes are sent to a non-SQL Server database server in near real time. You also need to ensure that data on the primary server is unaffected. Which configuration should you use?
A. SQL Server that includes an application database configured to perform transactional replication
B. Two servers configured in different data centers
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
C. Two servers configured in different data centers
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
One server configured as an Active Secondary
D. SQL Server that includes an application database configured to perform snapshot replication
E. Two servers configured in the same data center
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
One server configured as an Active Secondary
F. Two servers configured on the same subnet
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
G. Two servers configured in a Windows Failover Cluster in the same data center
SQL Server configured as a clustered instance
H. Two servers configured in the same data center
A primary server configured to perform log-shipping every 10 minutes
A backup server configured as a warm standby


Answer Clike
Which Transact-SQL query do you use?

You are a database developer for an application hosted on a Microsoft SQL Server 2012 server. The database contains two tables that have the following definitions:

Global customers place orders from several countries. You need to view the country from which each customer has placed the most orders. Which 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
WHERE 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
WHERE 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


Answer Clike
Which Transact-SQL query should you use?

You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as shown in the exhibit. (Click the Exhibit button.)

You need to display rows from the Orders table for the Customers row having the CustomerIdvalue set to 1 in the following XML format.

Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers=CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
F. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
G. SELECT Name AS ‘@Name’, Country AS ‘@Country’, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH (‘Customers’)
H. SELECT Name AS ‘Customers/Name’, Country AS ‘Customers/Country’, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH (‘Customers’)


Answer Clike
Which Transact-SQL query should you use?

You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as shown in the exhibit. (Click the Exhibit button.)

You need to display rows from the Orders table for the Customers row having the CustomerId value set to 1 in the following XML format.
<CUSTOMERS Name="Customer A" Country="Australia">
<ORDERS OrderID="1" OrderDate="2001-01-01" Amount="3400.00" />
<ORDERS OrderID="2" OrderDate="2002-01-01" Amount="4300.00" />
</CUSTOMERS>
Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO
F. SELECT Name, Country, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
G. SELECT Name AS ‘@Name’, Country AS ‘@Country’, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH (‘Customers’)
H. SELECT Name AS ‘Customers/Name’, Country AS ‘Customers/Country’, OrderId, OrderDate, Amount
FROM Orders INNER JOIN Customers ON Orders.CustomerId = Customers.CustomerId
WHERE Customers.CustomerId = 1
FOR XML PATH (‘Customers’)


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server. One of the databases on the server supports a highly active OLTP application. Users report abnormally long wait times when they submit data into the application. You need to identify which queries are taking longer than 1 second to run over an extended period of time. What should you do?
A. Use SQL Profiler to trace all queries that are processing on the server. Filter queries that have a Duration value of more than 1,000.
B. Use sp_configure to set a value for blocked process threshold. Create an extended event session.
C. Run the sp_who command from a query window.
D. Run the DBCC TRACEON 1222 command from a query window and review the SQL Server event log.
E. Use the Job Activity monitor to review all processes that are actively running. Review the Job History to find out the duration of each step.


Answer Clike
Which code segment should you use?

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.
A. CREATE FUNCTION Sales.fn_OrdersByTerritory (@T int)
RETURNS TABLE
AS
RETURN
(
SELECT OrderID,OrderDate,SalesTerrirotyID,TotalDue
FROM Sales.OrdersByTerritory
WHERE SalesTerritoryID = @T
)


Answer Clike
Which code segment should you use?

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.
A. CREATE TABLE Sales.OrderDetails (
ListPrice money not null,
Quantity int not null,
LineItemTotal as (ListPrice * Quantity) PERSISTED)
B. CREATE TABLE Sales.OrderDetails (
ListPrice money not null,
Quantity int not null,
LineItemTotal as
(ListPrice * Quantity))


Answer Clike
Which data type should you use?

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


Answer Clike
Which code segment should you add to line 14?

You use Microsoft SQL Server 2012 to create a stored procedure as shown in the following code segment. (Line numbers are included for reference only.)

The procedure can be called within other transactions. You need to ensure that when the DELETE statement from the HumanResourcesJobCandidate table succeeds, the modification is retained even if the insert into the Audit.Log table fails. Which 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 = 1


Answer Clike
Which code segment should you use?

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 write a Transact-SQL statement that will find out the success of a cast to a decimal (36,9). Which 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
WHEN 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


Answer Clike
Which object should you use?

You develop a Microsoft SQL Server 2012 database. You need to create a batch process that meets the following requirements:
• Status information must be logged to a status table.
• If the status table does not exist at the beginning of the batch, it must be created.
Which object should you use?
A. Scalar user-defined function
B. Inline user-defined function
C. Table-valued user-defined function
D. Stored procedure


Answer Clike
Which Transact-SQL statement should you use?

You administer a database that includes a table named Customers that contains more than 750 rows. 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 the following conditions:
• Always starts with 1.
• Starts again from 1 after it reaches 100.
Which Transact-SQL statement should you use?
A. CREATE SEQUENCE CustomerSequence AS int
START WITH 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 WITH 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 WITH 1
INCREMENT BY 1
MINVALUE 0
MAXVALUE 100
CYCLE
UPTATE Customers SET PartitionNumber = NEXT VALUE FOR CustomerSequence
DROP SEQUENCE CustomerSequence


Answer Clike
Which Transact-SQL statement should you use?

You use a Microsoft SQL Server 2012 database that contains a table named BlogEntry that has the following 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. Which Transact-SQL statement should you use?
A. UPDATE TOP(10) BlogEntry
SET Summary.WRITE(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))
WHERE 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. --this option was diferent im my exam
UPDATE BlogEntry
SET Summary.WRITE(N’ This is in a draft stage’, 0, 0)
WHERE Id IN(SELECT TOP(10) Id FROM BlogEntry ORDER BY EntryDateTime DESC)


Answer Clike
Which Transact-SQL statement should you use?

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. Which 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 @RowCountVar INT;
EXEC DeleteJobCandidate
SELECT @ErrorVar = ERROR_STATE(), @RowCountVar = @@ROWCOUNT;
IF (@ErrorVar <> 0)
PRINT N’Error = ‘ + CAST(ERRORSTATE() AS NVARCHAR(8)) +
N’, Rows Deleted = ‘ + CAST(@@RowCountVar AS NVARCHAR(8));
GO
C. EXEC DeleteJobCandidate
IF (ERROR_STATE() != 0)
PRINT N’Error = ‘ + CAST(@@ERROR AS NVARCHAR(8)) +
N’, Rows Deleted = ‘ + CAST(@@ROWCOUNT AS NVARCHAR(8));
GO
D. EXEC DeleteJobCandidate
PRINT N’Error = ‘ + CAST(@@ERROR AS NVARCHAR(8)) +
N’, Rows Deleted = ‘ + CAST(@@ROWCOUNT AS NVARCHAR(8));
GO


Answer Clike
What should you do?

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

You need to ensure that users are able to modify data by using the view. What should you do?
A. Create an AFTER trigger on the view.
B. Modify the view to use the WITH VIEW_METADATA clause.
C. Create an INSTEAD OF trigger on the view.
D. Modify the view to an indexed view.


Answer Clike
Which column in the Employee table should you a create a unique constraint?

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 a create a unique constraint?
A. DateHired
B. DepartmentID
C. EmployeelD
D. EmployeeNum
E. FirstName
F. JobTitle
G. LastName
H. MiddleName
I. ReportsToID


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

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


Answer Clike
Which Transact-SQL query should you use?

You administer a Microsoft SQL Server 2012 database that includes a table named Products. The Products table has columns named Productld, ProductName, and CreatedDateTime. The table contains a unique constraint on the combination of ProductName and CreatedDateTime. You need to modify the Products table to meet the following requirements:
• Remove all duplicates of the Products table based on the ProductName column.
• Retain only the newest Products row.
Which Transact-SQL query should you use?
A. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName
AND p.CreatedDateTime > cte.CreatedDateTime
B. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
cte.ProductName = p.ProductName
AND cte.CreatedDateTime > p.CreatedDateTime
C. WITH CTEDupRecords
AS
(
SELECT MIN(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName
D. WITH CTEDupRecords
AS
(
SELECT MAX(CreatedDateTime) AS CreatedDateTime, ProductName
FROM Products
GROUP BY ProductName
HAVING COUNT(*) > 1
)
DELETE p
FROM Products p
JOIN CTEDupRecords cte ON
p.ProductName = cte.ProductName


Answer Clike
Which Transact-SQL statement should you use?

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


Answer Clike
Which Transact-SQL query should you use?

You develop a Microsoft SQL Server 2012 database that contains tables named Customers and Orders. The tables are related by a column named CustomerId . You need to create a query that meets the following requirements:
• Returns the CustomerName for all customers and the OrderDate for any orders that they have placed.
• Results must not include customers who have not placed any orders.
Which Transact-SQL query should you use?
A. SELECT CustomerName, OrderDate
FROM Customers
LEFT OUTER JOIN Orders
ON Customers.CuscomerlD = Orders.CustomerId
B. SELECT CustomerName, OrderDate
FROM Customers
RIGHT OUTER JOIN Orders
ON Customers.CustomerID = Orders.CustomerId
C. SELECT CustomerName, OrderDate
FROM Customers
CROSS JOIN Orders
ON Customers.CustomerId = Orders.CustomerId
D. SELECT CustomerName, OrderDate
FROM Customers
JOIN Orders
ON Customers.CustomerId = Orders.CustomerId


Answer Clike
What should you create for each application?

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 applications.
What should you create for each application?
A. Synonyms
B. Common table expressions
C. Views
D. Temporary tables


Answer Clike
Which object should you use?

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


Answer Clike
Which Transact-SQL query or queries should you use?

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 AccountHolderlD
FROM AccountHolder
WHERE CityID <> SOME (SELECT CityID FROM BranchMaster)
D. SELECT AccountHolderID
FROM AccountHolder
WHERE CityID <> ANY (SELECT CityID FROM BranchMaster)


Answer Clike
What should you do?

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.


Answer Clike
Which isolation level should you use?

You use Microsoft SQL Server 2012 to write code for a transaction that contains several statements. There is high contention between readers and writers 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 writing queries. Which isolation level should you use?
A. SERIALIZABLE
B. SNAPSHOT
C. READ COMMITTED SNAPSHOT
D. REPEATABLE READ


Answer Clike
Which Transact-SQL statement should you use?

You administer a Microsoft SQL Server 2012. A process that normally runs in less than 10 seconds has been running for more than an hour. You examine the application log and discover that the process is using session ID 60. You need to find out whether the process is being blocked. Which Transact-SQL statement should you use?
A. SELECT * FROM sys.dm_exec_sessions WHERE session_id = 60
B. DBCC OPENTRAN
C. EXEC sp_helpdb 60
D. SELECT * FROM sys.dm_exec_requests WHERE session_id = 60


Answer Clike
Which Transact-SQL query should you use?

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. Which 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
WHERE 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
WHERE 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
WHERE Rank = 1


Answer Clike
Which Transact-SQL query should you use?

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 following 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 when the same rank is assigned.
Which 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
WHERE 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
WHERE 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
WHERE Rank = 1


Answer Clike
Which Transact-SQL query should you use?

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 who scored the highest marks for each subject along with the marks. Which 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
WHERE 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
WHERE 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
WHERE Rank = 1


Answer Clike
What should you do?

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.


Answer Clike
Which code segment should you use?

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

You have an application named Appl. You have a parameter named @Count that uses the int data type. App1 is configured to pass @Count to a stored procedure. You need to create a stored procedure named usp_Customers for Appl. Usp_Customers must meet the following requirements:
• NOT use object delimiters.
• Minimize sorting and counting.
• Return only the last name of each customer in alphabetical order.
• Return only the number of rows specified by the @Count parameter.
• The solution must NOT use BEGIN and END statements.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. CREATE PROCEDURE usp_Customers @Count int
AS
SELECT TOP(@Count) LastName
FROM Customers
ORDER BY LastName


Answer Clike
Which SELECT statement should you use?

You have a database that contains the tables as shown below:

You have a stored procedure named Procedure1. Procedure1 retrieves all order ids after a specific date. The rows for Procedure1 are not sorted. Procedure1 has a single parameter named Parameter1. Parameter1 uses the varchar type and is configured to pass the specific date to Procedure1. A database administrator discovers that OrderDate is not being compared correctly to Parameter1 after the data type of the column is changed to datetime. You need to update the SELECT statement to meet the following requirements:
• The code must NOT use aliases.
• The code must NOT use object delimiters.
• The objects called in Procedure1 must be able to be resolved by all users.
• OrderDate must be compared to Parameter1 after the data type of Parameter1 is changed to datetime.
Which SELECT statement should you use?
To answer, type the correct code in the answer area.
A. SELECT OrderID
FROM Orders
WHERE OrderDate>CONVERT(datetime,@Parameter1)
B. SELECT Orders.OrderID
FROM Orders
WHERE Orders.OrderDate>CONVERT(datetime,@Parameter1)


Answer Clike
Which Transact-SQL operator should you use?

You use Microsoft SQL Server 2012 database to develop a shopping cart application. You need to invoke a table-valued function for each row returned by a query. Which Transact-SQL operator should you use?
A. CROSS JOIN
B. UNPIVOT
C. PIVOT
D. CROSS APPLY


Answer Clike
Which Transact-SQL query should you use?

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)


Answer Clike
Which configuration should you use?

You administer all the deployments of Microsoft SQL Server 2012 in your company. A database contains a large product catalog that is updated periodically. You need to be able to send the entire product catalog to all branch offices on a monthly basis. Which configuration should you use?
A. Two servers configured in the same data center
A primary server configured to perform log-shipping every 10 minutes
A backup server configured as a warm standby
B. Two servers configured in the same data center
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
One server configured as an Active Secondary
C. SQL Server that includes an application database configured to perform snapshot replication
D. Two servers configured in different data centers
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
One server configured as an Active Secondary
E. Two servers configured on the same subnet
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
F. Two servers configured in different data centers
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
G. SQL Server that includes an application database configured to perform transactional replication
H. Two servers configured in a Windows Failover Cluster in the same data center
SQL Server configured as a clustered instance


Answer Clike
Which configuration should you use?

You administer all the deployments of Microsoft SQL Server 2012 in your company. You need to ensure that an OLTP database that uses a storage area network (SAN) remains available if any of the servers fail. You also need to minimize the amount of storage used by the database. Which configuration should you use?
A. • Two servers configured in different data centers
• SQL Server Availability Group configured in Synchronous-Commit Availability Mode
• One server configured as an Active Secondary
B. • SQL Server that includes an application database configured to perform transactional replication
C. • Two servers configured in the same data center
• SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
• One server configured as an Active Secondary
D. • Two servers configured in different data centers
• SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
E. • Two servers configured in the same data center
• A primary server configured to perform log-shipping every 10 minutes
• A backup server configured as a warm standby
F. • Two servers configured on the same subnet
• SQL Server Availability Group configured in Synchronous-Commit Availability Mode
G. • SQL Server that includes an application database configured to perform snapshot replication
H. • Two servers configured in a Windows Failover Cluster in the same data center
• SQL Server configured as a clustered instance


Answer Clike
Which code segment should you use?

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

You need to create a query for a report. The query must meet the following requirements:
• NOT use object delimiters.
• Return the most recent orders first.
• Use the first initial of the table as an alias.
• Return the most recent order date for each customer.
• Retrieve the last name of the person who placed the order.
• Return the order date in a column named MostRecentOrderDate that appears as the last column in the report.
The solution must support the ANSI SQL-99 standard.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. SELECT c.CustomerID -- optional
c.LastName, max(o.OrderDate) ‘MostRecentOrderDate’
FROM Customer c LEFT OUTER JOIN Orders o ON o.CustomerID = c.CustomerID
GROUP BY c.CustomerID, c.LastName
ORDER BY 3 DESC
B. select C.Lastname, P.MostRecentOrderDate
from customers AS C inner join
(
select customID, MostRecentOrderDate=max(orderDate) from orders group by customID
) P
on C.customerID=P.CustomerID
order by P.MostRecentOrderDate desc
C. SELECT C.LastName, O.OrderDate AS MostRecentOrderDate
FROM Customers AS C INNER JOIN Orders AS O
ON C.CustomerID = O.CustomerID
ORDER BY O.OrderDate DESC


Answer Clike
Which code segment should you use?

You have an XML schema collection named Sales.InvoiceSchema. You need to declare a variable of the XML type named XML1. The solution must ensure that XML1 is validated by using Sales.InvoiceSchema.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. Declare @XML1=XML(Sales.InvoiceSchema)
B. DECLARE @XML1 XML
@XML1 = Sales.InvoiceSchema
CREATE XML SCHEMA COLLECTION XML1 AS @XML1


Answer Clike
Which code segment should you use?

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

You need to create a query that returns a list of products from Sales.ProductCatalog. The solution must meet the following requirements:
• UnitPrice must be returned in descending order.
• The query must use two-part names to reference the table.
• The query must use the RANK function to calculate the results.
• The query must return the ranking of rows in a column named PriceRank.
• The list must display the columns in the order that they are defined in the table.
• PriceRank must appear last.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. SELECT ProductCatalog.CatID, ProductCatalog.CatName, ProductCatalog.ProductID, ProductCatalog.ProdName,
ProductCatalog.UnitPrice,
RANK() OVER (ORDER BY ProductCatalog.UnitPrice DESC) AS PriceRank
FROM Sales.ProductCatalog
ORDER BY ProductCatalog.UnitPrice DESC
B. 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


Answer Clike
Which code segment should you use?

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.
A. CREATE VIEW Sales.uv_CustomerFullName with Schemabinding
AS
SELECT FirstName, LastName
FROM Customers
B. CREATE VIEW Sales.uv_CustomerFullName
AS
SELECT FirstName, LastName
FROM Customers


Answer Clike
Which code segment should you use?

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.
A. SELECT OrderID, SUM(ExtendedAmount) AS TotalSales
FROM Sales.Details
GROUP BY OrderID
ORDER BY OrderID
B. SELECT OrderID, SUM(ExtendedAmount) AS TotalSales
FROM Sales.Details
ORDER BY OrderID


Answer Clike
Which code segment should you use?

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

You have the following query:

You need to recreate the query to meet the following requirements:
• Reference columns by using one-part names only.
• Sort aggregates by SalesTerritoryID, and then by ProductID.
• Order the results in descending order from SalesTerritoryID to ProductID.
• The solution must use the existing SELECT clause and FROM clause.
Which code segment should you use?
To answer, type the correct code in the answer area.
A. SELECT SalesTerritoryID,
AVG(UnitPrice),
MAX(OrderQty),
MAX(DiscountAmount)
FROM Sales.Details
GROUP BY SalesTerritoryID,ProductID
ORDER BY SalesTerritoryID DESC, ProductID DESC
B. SELECT SalesTerritoryID,
ProductID,
AVG(UnitPrice),
MAX(OrderQty),
MAX(DiscountAmount)
FROM Sales.Details
ORDER BY SalesTerritoryID DESC, ProductID DESC


Answer Clike
Which Transact-SQL statement should you use?

You are a database developer of a Microsoft SQL Server 2012 database. The database contains a table named Customers that has the following 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. Which Transact-SQL statement should you use?
A. ALTER TABLE Orders
ADD CONSTRAINT FK_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_Orders_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 (OrderID) REFERENCES Orders (OrderID);
E. ALTER TABLE Orders
ADD CONSTRAINT PK_Orders_CustomerID PRIMARY KEY (CustomerID)


Answer Clike
What should you do?

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


Answer Clike
What should you do?

You develop a Microsoft SQL Server 2012 database. You create a view that performs the following tasks:
• Joins 8 tables that contain up to 500,000 records each.
• Performs aggregations on 5 fields.
The view is frequently used in several reports. You need to improve the performance of the reports.
What should you do?
A. Convert the view into a table-valued function.
B. Convert the view into a Common Table Expression (CTE).
C. Convert the view into an indexed view.
D. Convert the view into a stored procedure and retrieve the result from the stored procedure into a temporary table.


Answer Clike
Which Transact-SQL query should you use?

You administer a Microsoft SQL Server 2012 database named ContosoDb. Tables are defined as shown in the exhibit. (Click the Exhibit button.)

You need to display rows from the Orders table for the Customers row having the Customerld value set to 1 in the following XML format.

Which Transact-SQL query should you use?
A. SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers-CustomerId WHERE Customers.CustomerId = 1
FOR XML RAW
B. SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE Customers.CustomerId = 1
FOR XML RAW, ELEMENTS
C. SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN Customers ON Orders.CustomerId =
Customers.CustomerId WHERE Customers.CustomerId = 1
FOR XML AUTO
D. SELECT OrderId, OrderDate, Amount, Name, Country FROM Orders INNER JOIN Customers ON Orders.CustomerId -
Customers.CustomerId WHERE Customers.CustomerId= 1
FOR XML AUTO, ELEMENTS
E. SELECT Name, Country, OrderId, OrderDate, Amount FROM Orders INNER JOIN Customers ON Orders.CustomerId=
Customers.CustomerId WHERE Customers.CustomerId = 1
FOR XML AUTO
F. SELECT Name, Country, OrderId, OrderDate, Amount FROM Orders INNER JOIN Customers ON Orders.CustomerId=
Customers.CustomerId WHERE Customers.CustomerId = 1
FOR XML AUTO, ELEMENTS
G. SELECT Name AS ‘@Name’, Country AS ‘@Country’, OrderId, OrderDate, Amount FROM Orders INNER JOIN Customers ON
Orders.CustomerId= Customers.CustomerId WHERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)
H. SELECT Name AS ‘Customers/Name’, Country AS ‘Customers/Country’, OrderId, OrderDate, Amount FROM Orders
INNER JOIN Customers ON Orders.CustomerId= Customers.CustomerId WHERE Customers.CustomerId= 1
FOR XML PATH (‘Customers’)


Answer Clike
Which Transact-SQL statement should you use?

You develop a Microsoft SQL Server 2012 server database that supports an application. The application contains a table that has the following definition:
CREATE TABLE Inventory (
ItemID int NOT NULL PRIMARY KEY,
ItemsInStore int NOT NULL,
ItemsInWarehouse int NOT NULL)
You need to create a computed column that returns the sum total of the ItemsInStore and ItemsInWarehouse values for each row. The new column is expected to be queried heavily, and you need to be able to index the column. Which Transact-SQL statement should you use?
A. ALTER TABLE Inventory
ADD TotalItems AS ItemslnStore + ItemsInWarehouse
B. ALTER TABLE Inventory
ADD TotalItems AS ItemsInStore + ItemsInWarehouse PERSISTED
C. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse) PERSISTED
D. ALTER TABLE Inventory
ADD TotalItems AS SUM(ItemsInStore, ItemsInWarehouse)


Answer Clike
Which Transact-SQL query should you use?

You develop a Microsoft SQL Server 2012 database that contains a table named Customers. The Customers table has the following definition:

You need to create an audit record only when either the MobileNumber or HomeNumber column is updated. Which Transact-SQL query should you use?
A. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_UPDATED (HomeNumber, MobileNumber)
- - Create Audit Records
B. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF EXISTS( SELECT HomeNumber FROM inserted) OR
EXISTS (SELECT MobileNumber FROM inserted)
- - Create Audit Records
C. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF COLUMNS_CHANGED (HomeNumber, MobileNumber)
- - Create Audit Records
D. CREATE TRIGGER TrgPhoneNumberChange
ON Customers FOR UPDATE
AS
IF UPDATE (HomeNumber) OR UPDATE (MobileNumber)
- - Create Audit Records


Answer Clike
Which Transact-SQL statement should you use?

You develop a Microsoft SQL Server 2012 database that has two tables named SavingAccounts and LoanAccounts. Both tables have a column named AccountNumber of the nvarchar data type. You use a third table named Transactions that has columns named TransactionId, AccountNumber, Amount, and TransactionDate. You need to ensure that when multiple records are inserted in the Transactions table, only the records that have a valid AccountNumber in the SavingAccounts or LoanAccounts are inserted. Which Transact-SQL statement should you use?
A. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted
WHERE AccountNumber IN
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
END
B. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
FOR INSERT
AS
BEGIN
INSERT INTO Transactions
SELECT TransactionID,AccountNumber,Amount,TransactionDate FROM inserted
WHERE AccountNumber IN
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
END
C. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
INSTEAD OF INSERT
AS
BEGIN
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END
D. CREATE TRIGGER TrgValidateAccountNumber
ON Transactions
FOR INSERT
AS
BEGIN
IF EXISTS (
SELECT AccountNumber FROM inserted EXCEPT
(SELECT AccountNumber FROM LoanAccounts
UNION SELECT AccountNumber FROM SavingAccounts))
BEGIN
ROLLBACK TRAN
END
END


Answer Clike
What should you do?

You are developing a database application by using Microsoft SQL Server 2012. An application that uses a database begins to run slowly. Your investigation shows the root cause is a query against a read-only table that has a clustered index. The query returns the following six columns:
• One column in its WHERE 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. What 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 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.


Answer Clike
What should you do?

You are developing a database application by using Microsoft SQL Server 2012. An application that uses a database begins to run slowly. You discover that a large amount of memory is consumed by single-use dynamic queries. You need to reduce procedure cache usage from these statements without creating any additional indexes. What 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 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.


Answer Clike
What should you do?

You are developing a database application by using Microsoft SQL Server 2012. You have a query that runs slower than expected. You need to capture execution plans that will include detailed information on missing indexes recommended by the query optimizer. What 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 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.


Answer Clike
What should you do?

You are developing a database application by using Microsoft SQL Server 2012. An application that uses a database begins to run slowly. You discover that during reads, the transaction experiences blocking from concurrent updates. You need to ensure that throughout the transaction the data maintains the original version. What 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 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.


Answer Clike
Which Transact- SQL statement should you use?

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 PRIMARY KEY CLUSTERED,
CustomerID int NOT NULL PRIMARY KEY CLUSTERED,
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 UQ_Customer UNIQUE CLUSTERED
(SourceID, CustomerID));


Answer Clike
Which Transact-SQL statement should you use?

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

You create a view named VwEmployee as shown in the following 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 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


Answer Clike
Which Transact-SQL operator should you use?

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


Answer Clike
Which approach should you use?

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 will execute the stored procedure based on the country of residence. Which 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


Answer Clike
Which Transact-SQL statement should you use?

You use Microsoft SQL Server 2012 to develop a database application. You create a stored procedure named dbo.ModifyData that can modify rows. You need to ensure that when the transaction fails, dbo.ModifyData meets the following requirements:
• Does not return an error
• Closes all opened transactions
Which 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


Answer Clike
Which table hint should you use?

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


Answer Clike
Which Transact-SQL query should you use?

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


Answer Clike
What should you do?

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.


Answer Clike
What should you do?

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


Answer Clike
What should you do?

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


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 database. You need to ensure that the size of the transaction log file does not exceed 2 GB. What should you do?
A. Execute sp_configure ‘max log size’, 2G.
B. use the ALTER DATABASE…SET LOGFILE command along with the maxsize parameter.
C. In SQL Server Management Studio, right-click the instance and select Database Settings. Set the maximum size of the file for the transaction log.
D. in SQL Server Management Studio, right-click the database, select Properties, and then click Files.
Open the Transaction log Autogrowth window and set the maximum size of the file.


Answer Clike
Which Transact-SQL statement should you use before attempting the restore?

You administer a Microsoft SQL Server 2012 database. You configure Transparent Data Encryption (TDE) on the Orders database by using the following statements:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘MyPassword1!’;
CREATE CERTIFICATE TDE_Certificate WITH SUBJECT = ‘TDE Certificate’;
BACKUP CERTIFICATE TDE_Certificate TO FILE = ‘d:TDE_Certificate.cer’
WITH PRIVATE KEY (FILE = ‘d:TDE_Certificate.key’, ENCRYPTION BY PASSWORD = ‘MyPassword1!’);
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate;
ALTER DATABASE Orders SET ENCRYPTION ON;
You attempt to restore the Orders database and the restore fails. You copy the encryption file to the original location. A hardware failure occurs and so a new server must be installed and configured. After installing SQL Server to the new server, you restore the Orders database and copy the encryption files to their original location. However, you are unable to access the database. You need to be able to restore the database. Which Transact-SQL statement should you use before attempting the restore?
A. CREATE ASSEMBLY TDE_Assembly
FROM ‘d:TDE_Certificate.cer’
WITH PERMISSION_SET = SAFE;
GO
CREATE CERTIFICATE TDE_Certificate
FROM ASSEMBLY TDE_Assembly;
B. CREATE CERTIFICATE TDE_Certificate
FROM EXECUTABLE FILE = ‘d:TDE_Certificate.cer’
C. CREATE CERTIFICATE TDE_Certificate
FROM FILE = ‘d:TDE_Certificate.cer’
WITH PRIVATE KEY (FILE = ‘d:TDE_Certificate.key’, DECRYPTION BY PASSWORD ‘MyPassword1!’);
D. DECLARE @startdate date
SET @startdate = GETDATE()
CREATE CERTIFICATE TDE_Certificate
FROM FILE = ‘d:TDE_Certificate.cer’
WITH START_DATE = @startdate;


Answer Clike
Which server-level audit action group should you use?

You administer a Microsoft SQL Server 2012 database. You provide temporary securityadmin access to User1 to the database server. You need to know if User1 adds logins to securityadmin. Which server-level audit action group should you use?
A. SERVER_STATE_CHANGE_GROUP
B. SERVER_PRINCIPAL_IMPERSONATION_GROUP
C. SUCCESSFUL_LOGIN_GROUP
D. SERVER_ROLE_MEMBER_CHANGE_GROUP


Answer Clike
Which backup option should you use?

You administer a Microsoft SQL Server 2012 instance that contains a financial database hosted on a storage area network (SAN). The financial database has the following characteristics:
• A data file of 2 terabytes is located on a dedicated LUN (drive D).
• A transaction log of 10 GB is located on a dedicated LUN (drive E).
• Drive D has 1 terabyte of free disk space.
• Drive E has 5 GB of free disk space.
The database is continually modified by users during business hours from Monday through Friday between 09:00 hours and 17:00 hours. Five percent of the existing data is modified each day. The Finance department loads large CSV files into a number of tables each business day at 11:15 hours and 15:15 hours by using the BCP or BULK INSERT commands. Each data load adds 3 GB of data to the database. These data load operations must occur in the minimum amount of time. A full database backup is performed every Sunday at 10:00 hours. Backup operations will be performed every two hours (11:00, 13:00, 15:00, and 17:00) during business hours. You need to ensure that your backup will continue if any invalid checksum is encountered.
Which backup option should you use?
A. STANDBY
B. Differential
C. FULL
D. CHECKSUM
E. BULK_LOGGED
F. CONTINUE_AFTER_ERROR
G. SIMPLE
H. DBO_ONLY
I. COPY_ONLY
J. SKIP
K. RESTART
L. Transaction log
M. NO_CHECKSUM
N. NORECOVERY


Answer Clike
Which backup option should you use?

You administer a Microsoft SQL Server 2012 instance that contains a financial database hosted on a storage area network (SAN). The financial database has the following characteristics:
• A data file of 2 terabytes is located on a dedicated LUN (drive D).
• A transaction log of 10 GB is located on a dedicated LUN (drive E).
• Drive D has 1 terabyte of free disk space.
• Drive E has 5 GB of free disk space.
The database is continually modified by users during business hours from Monday through Friday between 09:00 hours and 17:00 hours. Five percent of the existing data is modified each day. The Finance department loads large CSV files into a number of tables each business day at 11:15 hours and 15:15 hours by using the BCP or BULK INSERT commands. Each data load adds 3 GB of data to the database. These data load operations must occur in the minimum amount of time. A full database backup is performed every Sunday at 10:00 hours. Backup operations will be performed every two hours (11:00, 13:00, 15:00, and 17:00) during business hours. On Wednesday at 10:00 hours, the development team requests you to refresh the database on a development server by using the most recent version. You need to perform a full database backup that will be restored on the development server.
Which backup option should you use?
A. NORECOVERY
B. FULL
C. NO_CHECKSUM
D. CHECKSUM
E. Differential
F. 8ULK_LOGGED
G. STANDBY
H. RESTART
I. SKIP
J. Transaction log
K. DBO ONLY
L. COPY_ONLY
M. SIMPLE
N. CONTINUE AFTER ERROR


Answer Clike
Which backup should you perform every two hours?

You administer a Microsoft SQL Server 2012 instance that contains a financial database hosted on a storage area network (SAN). The financial database has the following characteristics:
• A data file of 2 terabytes is located on a dedicated LUN (drive D).
• A transaction log of 10 GB is located on a dedicated LUN (drive E).
• Drive D has 1 terabyte of free disk space.
• Drive E has 5 GB of free disk space.
The database is continually modified by users during business hours from Monday through Friday between 09:00 hours and 17:00 hours. Five percent of the existing data is modified each day. The Finance department loads large CSV files into a number of tables each business day at 11:15 hours and 15:15 hours by using the BCP or BULK INSERT commands. Each data load adds 3 GB of data to the database. These data load operations must occur in the minimum amount of time. A full database backup is performed every Sunday at 10:00 hours. Backup operations will be performed every two hours (11:00, 13:00, 15:00, and 17:00) during business hours. You need to ensure that the backup size is as small as possible. Which backup should you perform every two hours?
A. BULK_LOGGED
B. NO_CHECKSUM
C. FULL
D. RESTART
E. CHECKSUM
F. STANDBY
G. DBO.ONLY
H. NORECOVERY
I. SIMPLE
J. Transaction log
K. Differential
L. CONTINUE_AFTER_ERROR
M. COPY_ONLY
N. SKIP


Answer Clike
Which Transact-SQL statement should you use?

You administer a Microsoft SQL Server 2012 database named 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 rows that are not active from Suppliers. You also need to grant ContosoUser only the minimum required permissions. Which Transact-SQL statement should you use?
A. GRANT DELETE ON Purchases.Suppliers TO ContosoUser
B. CREATE PROCEDURE Purchases.PurgeInactiveSuppliers
WITH EXECUTE AS USER = ‘dbo’
AS
DELETE FROM Purchases.Suppliers WHERE 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


Answer Clike
Which type of user should you create?

You use a contained database named ContosoDb within a domain. You need to create a user who can log on to the ContosoDb database. You also need to ensure that you can port the database to different database servers within the domain without additional user account configurations. Which type of user should you create?
A. User mapped to a certificate
B. SQL user without login
C. Domain user
D. SQL user with login


Answer Clike
Which SQL statement or statements should you use?

You are the lead database administrator (DBA) of a Microsoft SQL Server 2012 environment. All DBAs are members of the DOMAINJrDBAs Active Directory group. You grant DOMAINJrDBAs access to the SQL Server. You need to create a server role named SpecialDBARole that can perform the following functions:
• View all databases.
• View the server state.
• Assign GRANT, DENY, and REVOKE permissions on logins.
You need to add DOMAINJrDBAs to the server role. You also need to provide the least level of privileges necessary. Which SQL statement or statements should you use? Choose all that apply.
A. CREATE SERVER ROLE [SpecialDBARole] AUTHORIZATION setupadmin;
B. ALTER SERVER ROLE [SpecialDBARole] ADD MEMBER [DOMAINJrDBAs];
C. CREATE SERVER ROLE [SpecialDBARole] AUTHORIZATION securityadmin;
D. GRANT VIEW DEFINITION TO [SpecialDBARole];
E. CREATE SERVER ROLE [SpecialDBARole] AUTHORIZATION serveradmin;
F. GRANT VIEW SERVER STATE, VIEW ANY DATABASE TO [SpecialDBARole];


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 database that has Trustworthy set to On. You create a stored procedure that returns database-level information from Dynamic Management Views. You grant User1 access to execute the stored procedure. You need to ensure that the stored procedure returns the required information when User1 executes the stored procedure. You need to achieve this goal by granting the minimum permissions required. What should you do? (Each correct answer presents a complete solution. Choose all that apply.)
A. Create a SQL Server login that has VIEW SERVER STATE permissions.
Create an application role and a secured password for the role.
B. Modify the stored procedure to include the EXECUTE AS OWNER statement.
Grant VIEW SERVER STATE permissions to the owner of the stored procedure.
C. Create a SQL Server login that has VIEW SERVER STATE permissions.
Modify the stored procedure to include the EXECUTE AS {newlogin} statement.
D. Grant the db_owner role on the database to User1.
E. Grant the sysadmin role on the database to User1.


Answer Clike
What should you configure?

You administer a Microsoft SQL Server 2012 server. When transaction logs grow, SQL Server must send an email message to the database administrators. You need to configure SQL Server to send the email messages. What should you configure?
A. SQL Mail
B. An Extended Events session
C. Alerts and operators in SQL Server Agent
D. Policies under Policy-Based Management


Answer Clike
Which permission or permissions should you assign to UserC?

You administer a Microsoft SQL Server 2012 database. The database has a table named Customers owned by UserA and another table named Orders owned by UserB. You also have a stored procedure named GetCustomerOrderInfo owned by UserB. GetCustomerOrderInfo selects data from both tables.
You create a new user named UserC. You need to ensure that UserC can call the GetCustomerOrderInfo stored procedure. You also need to assign only the minimum required permissions to UserC. Which permission or permissions should you assign to UserC? Choose all that apply.
A. The Select permission on Customers
B. The Execute permission on GetCustomerOrderInfo
C. The Take Ownership permission on Customers
D. The Control permission on GetCustomerOrderInfo
E. The Take Ownership permission on Orders
F. The Select permission on Orders


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 instance that has several SQL Server Agent jobs configured. When SQL Server Agent jobs fail, the error messages returned by the job steps are truncated. The following error message is an example of the truncated error message:
"Executed as user CONTOSOServiceAccount. …0.4035.00 for 64-bit Copyright (C) Microsoft Corp 1984-2011. All rights reserved. Started 63513 PM Error 2012-06-23 183536.87 Code 0XC001000E Source UserImport Description Code 0x00000000 Source Log Import Activity Descript… The package execution fa… The step failed."
You need to ensure that all the details of the job step failures are retained for SQL Server Agent jobs.
What should you do?
A. Expand agent logging to include information from all events.
B. Disable the Limit size of job history log feature.
C. Configure event forwarding.
D. Configure output files.


Answer Clike
Which

You administer a Microsoft SQL Server 2012 database. You create an availability group named haContosoDbs. Your primary replica is available at Server01Contoso01. You need to configure the availability group to have the highest availability. You also need to ensure that no data is lost. Which
Transact-SQL statement should you use?
A. ALTER AVAILABILITY GROUP haContosoDbs MODIFY REPLICA ON ‘Server01Contoso01’
WITH (AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, FAILOVER_MODE = AUTOMATIC)
B. ALTER AVAILABILITY GROUP haContosoDbs MODIFY REPLICA ON ‘Server01Contoso01’
WITH (AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, FAILOVER_MODE = MANUAL)
C. ALTER AVAILABILITY GROUP haContosoDbs MODIFY REPLICA ON ‘Server01Contoso01’
WITH (AVAILABILITY_MODE = SYNCHRONOUS_COMMIT, FAILOVER_MODE = AUTOMATIC)
D. ALTER AVAILABILITY GROUP haContosoDbs MODIFY REPLICA ON ‘Server01Contoso01’
WITH (AVAILABILITY_MODE = ASYNCHRONOUS_COMMIT, FAILOVER_MODE = MANUAL)


Answer Clike
What should you do?

You administer several Microsoft SQL Server 2012 database servers. Merge replication has been configured for an application that is distributed across offices throughout a wide area network (WAN). Many of the tables involved in replication use the XML and varchar(max) data types. Occasionally, merge replication fails due to timeout errors. You need to reduce the occurrence of these timeout errors. What should you do?
A. Set the Merge agent on the problem subscribers to use the slow link agent profile.
B. Create a snapshot publication, and reconfigure the problem subscribers to use the snapshot publication.
C. Change the Merge agent on the problem subscribers to run continuously.
D. Set the Remote Connection Timeout on the Publisher to 0.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server that hosts a transactional database and a reporting database. The transactional database is updated through a web application and is operational throughout the day. The reporting database is only updated from the transactional database. The recovery model and backup schedule are configured as shown in the following table:

At 16:20 hours, you discover that pages 17, 137, and 205 on one of the database files are corrupted on the transactional database. You need to ensure that the transactional database is restored. You also need to ensure that data loss is minimal. What should you do?
A. Perform a partial restore.
B. Restore the latest full backup, and restore the latest differential backup. Then, restore each log backup taken before the time of failure from the most recent differential backup.
C. Perform a point-in-time restore.
D. Restore the latest full backup.
E. Restore the latest full backup, and restore the latest differential backup. Then, restore the latest log backup.
F. Perform a page restore.
G. Restore the latest full backup. Then, restore each differential backup taken before the time of failure from the most recent full backup.
H. Restore the latest full backup. Then, restore the latest differential backup.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server that hosts a transactional database and a reporting database. The transactional database is updated through a web application and is operational throughout the day. The reporting database is only updated from the transactional database. The recovery model and backup schedule are configured as shown in the following table:

At 14:00 hours, you discover that pages 71, 520, and 713 on one of the database files are corrupted on the reporting database. You need to ensure that the databases are restored. You also need to ensure that data loss is minimal. What should you do?
A. Perform a partial restore.
B. Restore the latest full backup, and restore the latest differential backup. Then, restore each log backup taken before the time of failure from the most recent differential backup.
C. Restore the latest full backup.
D. Restore the latest full backup, and restore the latest differential backup. Then, restore the latest log backup.
E. Perform a page restore.
F. Restore the latest full backup. Then, restore each differential backup taken before the time of failure from the most recent full backup.
G. Perform a point-in-time restore.
H. Restore the latest full backup. Then, restore the latest differential backup.


Answer Clike
What should you create for each application?

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


Answer Clike
Which object should you use?

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


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server that hosts a transactional database and a reporting database. The transactional database is updated through a web application and is operational throughout the day. The reporting database is only updated from the transactional database. The recovery model and backup schedule are configured as shown in the following table:

The differential backup of the reporting database fails. Then, the reporting database fails at 14:00 hours. You need to ensure that the reporting database is restored. You also need to ensure that data loss is minimal. What should you do?
A. Restore the latest full backup, and restore the latest differential backup. Then, restore the latest log backup.
B. Perform a point-in-time restore.
C. Restore the latest full backup.
D. Restore the latest full backup, and restore the latest differential backup. Then, restore each log backup taken before the time of failure from the most recent differential backup.
E. Restore the latest full backup. Then, restore the latest differential backup.
F. Restore the latest full backup. Then, restore each differential backup taken before the time of failure from the most recent full backup.
G. Perform a page restore.
H. Perform a partial restore.


Answer Clike
What should you do? Choose all that apply.

You administer a Microsoft SQL Server 2012 default instance. The instance is hosted by a server that has a local firewall configured. The firewall only allows inbound connections on port 1433. The server only hosts a single instance of SQL Server. You need to ensure that the instance is configured to allow remote connections even if the SQL Server is unresponsive to client connections. What should you do? Choose all that apply.
A. Enable inbound connections on TCP port 1434 in the Windows Firewall on the server.
B. Execute the following Transact-SQL command: sp_configure ‘remote admin connections’,
C. Execute the Reconfigure command.
D. Execute the following Transact-SQL command:
sp_configure ‘remote access’, 1
E. Restart the SQL Server Agent Service.
F. Enable inbound connections on TCP port 135 in the Windows Firewall on the server.


Answer Clike
What should you do?

You administer two instances of Microsoft SQL Server 2012. You deploy an application that uses a database on the named instance. The application is unable to connect to the database on the named instance. You need to ensure that the application can connect to the named instance. What should you do?
A. Use the Data Quality Client to configure the application.
B. Start the SQL Server Browser Service.
C. Start the SQL Server Integration Services Service.
D. Use the Master Data Services Configuration Manager to configure the application.


Answer Clike
What should you do?

You are creating an application that will connect to the AgentPortal database by using a SQL login named AgentPortalUser. Stored procedures in the database will use sp_send_dbmail to send email messages. You create a user account in the msdb database for the AgentPortalUser login. You use the Database Mail Configuration Wizard to create a Database Mail profile. Security has not been configured for the Database Mail profile. You need to ensure that AgentPortalUser can send email messages. What should you do?
A. In the Database Mail Configuration Wizard, configure the Database Mail profile as a private profile for the AgentPortalUser account.
B. Disable the guest user in the msdb database.
C. Use the sysmail_help_profileaccount_sp stored procedure to add accounts to the Database Mail profile.
D. In the Database Mail Configuration Wizard, create an email account for each recipient’s email address in the Database Mail profile.


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 database. The database contains a customer table created by using the following definition:

You need to ensure that the minimum amount of disk space is used to store the data in the customer table. What should you do?
A. Implement row-level compression.
B. Implement page-level compression.
C. Convert all indexes to Column Store indexes.
D. Implement Unicode compression.


Answer Clike
Which Transact-SQL statement should you use before attempting the restore?

You administer a Microsoft SQL Server 2012 database. You configure Transparent Data Encryption (TDE) on the Orders database by using the following statements:
CREATE MASTER KEY ENCRYPTION BY PASSWORD = ‘MyPassword1!’
CREATE CERTIFICATE TDE_Certificate WITH SUBJECT = ‘TDE Certificate’;
BACKUP CERTIFICATE TDE_Certificate TO FILE = ”d:TDE_Certificate.cer’
WITH PRIVATE KEY (FILE = ‘D:TDE_Certificate.key’, ENCRYPTION BY PASSWORD = ‘MyPassword1!’);
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate;
ALTER DATABASE Orders SET ENCRYPTION ON;
You attempt to restore the Orders database and the restore fails. You copy the encryption file to the original location. A hardware failure occurs and so a new server must be installed and configured. After installing SQL Server to the new server, you restore the Orders database and copy the encryption files to their original location. However, you are unable to access the database. You need to be able to restore the database. Which Transact-SQL statement should you use before attempting the restore?
A. ALTER DATABASE Master SET ENCRYPTION OFF;
B. CREATE CERTIFICATE TDE_Certificate FROM FILE = ‘d:TDE_Certificate.cer’
WITH PRIVATE KEY (FILE = ‘D:TDE_Certificate.key’, DECRYPTION BY PASSWORD = ‘MyPassword1!’);
C. CREATE CERTIFICATE TDE_Certificate WITH SUBJECT = ‘TDE Certificate’;
USE Orders;
CREATE DATABASE ENCRYPTION KEY
WITH ALGORITHM = AES_256
ENCRYPTION BY SERVER CERTIFICATE TDE_Certificate;
D. CREATE CERTIFICATE TDE_Certificate FROM FILE = ‘d:TDE_Certificate.cer’;


Answer Clike
Which Transact-SQL statement should you use?

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 UserA is disallowed to select from any of the tables in the Customers schema. Which Transact-SQL statement should you use?
A. DENY SELECT ON Object::Regions FROM UserA
B. DENY SELECT ON Object::Regions FROM Sales
C. REVOKE SELECT ON Schema::Customers FROM Sales
D. REVOKE SELECT ON Schema::Customers FROM UserA
E. REVOKE SELECT ON Object::Regions FROM Sales
F. REVOKE SELECT ON Object::Regions FROM UserA
G. DENY SELECT ON Schema::Customers FROM Sales
H. DENY SELECT ON Schema::Customers FROM UserA
I. EXEC sp_addrolemember ‘Sales’, ‘UserA’
J. EXEC sp droprolemember ‘Sales’, ‘UserA’


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 failover cluster that contains two nodes named Node A and Node B. A single instance of SQL Server is installed on the cluster. An additional node named Node C has been added to the existing cluster. You need to ensure that the SQL Server instance can use all nodes of the cluster. What should you do?
A. Create a ConfigurationFile.ini file from Node B, and then run the AddNode command-line tool on Node A.
B. Use Node A to install SQL Server on Node C.
C. Run the Add Node to SQL Server Failover Cluster Wizard on Node C.
D. Use Cluster Administrator to add a new Resource Group to Node B.


Answer Clike
What should you do?

You administer two instances of Microsoft SQL Server 2012. You deploy an application that uses a database on the named instance. The application is unable to connect to the database on the named instance. You need to ensure that the application can connect to the named instance. What should you do?
A. Configure the application as data-tiered.
B. Open port 1433 on the Windows firewall on the server.
C. Configure the named SQL Server instance to use an account that is a member of the Domain Admins group.
D. Start the SQL Server Browser Service.


Answer Clike
What should you create?

You administer a Microsoft SQL Server 2012 database named Contoso on a server named Server01. You need to diagnose deadlocks that happen when executing a specific set of stored procedures by recording events and playing them back on a different test server. What should you create?
A. an Extended Event session
B. a Policy
C. a Database Audit Specification
D. an Alert
E. a Server Audit Specification
F. a SQL Profiler Trace
G. a Resource Pool


Answer Clike
Which Transact-SQL statement should you use?

You administer a Microsoft SQL Server 2012. A process that normally runs in less than 10 seconds has been running for more than an hour. You examine the application log and discover that the process is using session ID 60. You need to find out whether the process is being blocked. Which Transact-SQL statement should you use?
A. EXEC sp_who 60
B. SELECT * FROM sys.dm_exec_sessions WHERE sessionid = 60
C. EXEC sp_helpdb 60
D. DBCC INPUTBUFFER (60)


Answer Clike
Which configuration should you use?

You administer all the deployments of Microsoft SQL Server 2012 in your company. You have two servers in the same data center that hosts your production database. You need to ensure that the database remains available if a catastrophic server failure or a disk failure occurs. You also need to maintain transactional consistency of the data across both servers. You need to achieve these goals without manual intervention. Which configuration should you use?
A. Two servers configured in a Windows Failover Cluster in the same data center
SQL Server configured as a clustered instance
B. SQL Server that includes an application database configured to perform transactional replication
C. Two servers configured in the same data center
A primary server configured to perform log-shipping every 10 minutes
A backup server configured as a warm standby
D. Two servers configured in different data centers
SQL Server Availability Group configured in Synchronous-Commit Availability Mode
One server configured as an Active Secondary
E. Two servers configured in the same data center
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
One server configured as an Active Secondary
F. Two servers configured in different data centers
SQL Server Availability Group configured in Asynchronous-Commit Availability Mode
G. SQL Server that includes an application database configured to perform snapshot replication
H. Two servers configured on the same subnet
SQL Server Availability Group configured in Synchronous-Commit Availability Mode


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 instance that has several SQL Server Agent jobs configured. When SQL Server Agent jobs fail, the error messages returned by the job steps do not provide the required detail. The following error message is an example error message:
"The job failed. The Job was invoked by User CONTOSOServiceAccount. The last step to run was step 1 (Subplan_1)."
You need to ensure that all available details of the job step failures for SQL Server Agent jobs are retained.
What should you do?
A. Configure output files.
B. Expand agent logging to include information from all events.
C. Disable the Limit size of job history log feature.
D. Configure event forwarding.


Answer Clike
What should you create?

You administer a Microsoft SQL Server 2012 database named Contoso on a server named Server01. You need to be notified immediately when fatal errors occur on Server01. What should you create?
A. an Alert
B. a Server Audit Specification
C. an Extended Event session
D. a Resource Pool
E. a Policy
F. a SQL Profiler Trace
G. a Database Audit Specification


Answer Clike
What should you do?

You administer a Microsoft SQL Server 2012 server. You plan to deploy new features to an application. You need to evaluate existing and potential clustered and non-clustered indexes that will improve performance. What should you do?
A. Query the sys.dm_db_index_usage_stats DMV.
B. Query the sys.dm_db_missing_index_details DMV.
C. Use the Database Engine Tuning Advisor.
D. Query the sys.dm_db_missing_index_columns DMV.


Answer Clike
Which Transact-SQL statement should you use?

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


Answer Clike
What should you do on Saturday?

You administer a Microsoft SQL Server 2012 instance named SQL2012 that hosts an OLTP database of 1 terabyte in size. The database is modified by users only from Monday through Friday from 09:00 hours to 17:00 hours. Users modify more than 30 percent of the data in the database during the week. Backups are performed as shown in the following schedule:

The Finance department plans to execute a batch process every Saturday at 09:00 hours. This batch process will take a maximum of 8 hours to complete. The batch process will update three tables that are 10 GB in size. The batch process will update these tables multiple times. When the batch process completes, the Finance department runs a report to find out whether the batch process has completed correctly. You need to ensure that if the Finance department disapproves the batch process, the batch operation can be rolled back in the minimum amount of time. What should you do on Saturday?
A. Perform a differential backup at 08:59 hours.
B. Record the LSN of the transaction log at 08:59 hours. Perform a transaction log backup at 17:01 hours.
C. Create a database snapshot at 08:59 hours.
D. Record the LSN of the transaction log at 08:59 hours. Perform a transaction log backup at 08:59 hours.
E. Create a marked transaction in the transaction log at 08:59 hours. Perform a transaction log backup at 17:01 hours.
F. Create a marked transaction in the transaction log at 08:59 hours. Perform a transaction log backup at 08:59 hours.


Answer Clike
Which Transact-SQL batch should you use?

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


Answer Clike
What should you do?

You administer a Microsoft SQL Server database named Sales. The database is 3 terabytes in size. The Sales database is configured as shown in the following table.

You discover that all files except Sales_2.ndf are corrupt. You need to recover the corrupted data in the minimum amount of time. What should you do?
A. Perform a restore from a full backup.
B. Perform a transaction log restore.
C. Perform a file restore.
D. Perform a filegroup restore.


Answer Clike
Which Transact-SQL statement should you include at the beginning of the stored procedure?

You are writing a set of queries against a FILESTREAM-enabled database. 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 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


Answer Clike
Which Transact-SQL query should you use?

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, 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


Answer Clike
Which Transact-SQL statement should you include at the beginning of the stored procedure?

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


Answer Clike
Which query should you use?

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


Answer Clike