Q1. You use SQL Azure to store data used by an e-commerce application.
You develop a stored procedure named sp1. Sp1 is used to read and change the price of all the products sold on the e-commerce site.
You need to ensure that other transactions are blocked from updating product data while sp1 is executing.
Which transaction isolation level should you use in sp1?
A. Repeatable read
B. Read committed
C. Serializable
D. Snapshot
Answer: C
Q2. Topic 7)
You need to optimize the index and table structures for POSTransaction.
Which task should you use with each maintenance step? To answer, drag the appropriate tasks to the correct maintenance steps. Each task 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.
Answer:
Q3. You have a table named Rooms that contains three columns. You execute the following query:
You discover the execution plan shown in the exhibit. (Click the Exhibit button.)
You need to recommend a solution to reduce the amount of time it takes to execute the query.
What should you do?
More than one answer choice may achieve the goal. Select the BEST answer.
A. Include the RoomName column and the Position column in the Room_IX index.
B. Create a nonclustered index for RoomName, Id, and Position.
C. Create a clustered index for Id.
D. Use the WITH (INDEX(Room_IX),NOLOCK) query hint.
Answer: B
Q4. You attempt to process an invoice by using usp_InsertInvoice.sql and you receive the following error message: "Msg 515, Level 16, State 2, Procedure usp_InsertInvoice, Line 10
Cannot insert the value NULL into column 'InvoiceDate', table 'DB1.Accounting.Invoices' column does not allow nulls. INSERT fails."
You need to modify usp_InsertInvoice.sql to resolve the error.
How should you modify the INSERT statement?
A. InvoiceDate varchar(l00) 'InvoiceDate',
B. InvoiceDate varchar(100) 'Customer/InvoiceDate', '
C. InvoiceDate date '@InvoiceDate',
D. InvoiceDate date 'Customer/@InvoiceDate',
Answer: C
Topic 2, Scenario 2
Application Information
You have two servers named SQL1 and SQL2 that have SQL Server 2012 installed.
You have an application that is used to schedule and manage conferences.
Users report that the application has many errors and is very slow.
You are updating the application to resolve the issues.
You plan to create a new database on SQL1 to support the application. A junior database administrator has created all the scripts that will be used to create the database. The script that you plan to use to create the tables for the new database is shown in Tables.sql. The script that you plan to use to create the stored procedures for the new database is shown in StoredProcedures.sql. The script that you plan to use to create the indexes for the new database is shown in Indexes.sql. (Line numbers are included for reference only.)
A database named DB2 resides on SQL2. DB2 has a table named SpeakerAudit that will audit changes to a table named Speakers.
A stored procedure named usp_UpdateSpeakersName will be executed only by other stored procedures. The stored procedures executing usp_UpdateSpeakersName will always handle transactions.
A stored procedure named usp_SelectSpeakersByName will be used to retrieve the names of speakers. Usp_SelectSpeakersByName can read uncommitted data.
A stored procedure named usp_GetFutureSessions will be used to retrieve sessions that will occur in the future.
Procedures.sql
Indexes.sql Tables.sql
11. You are evaluating the index design.
You need to recommend a change to Indexes.sql that will minimize the amount of time it takes for usp_AttendeesReport to execute. The solution must minimize the amount of database fragmentation.
Which line of code should you use to replace line 12 of Indexes.sql?
A. (LastName);
B. (FirstName) INCLUDE (LastName);
C. (LastName, FirstName);
D. (LastName) INCLUDE (FirstName);
Q5. Topic 8)
You create a table that contains the following script:
You need to prevent duplicate values in the EmployeeID field.
Which five code segments should you use?
To answer, move the appropriate code segments from the list of code segments to the
answer area and arrange them in the correct order.
Answer:
Q6. You administer an instance of SQL Server 2014.
You are tasked with tuning a common set of queries. You have the results of several test executions, along with query plans. The schema and the data for all database object(s) used remain unchanged between executions. The QueryTime column is defined as a computed column that uses the GETDATE() system function. The query plans and results are shown below: You need to make an initial diagnosis of the situation, based solely on this input
Which two statements can you make about the performance characteristics of this query? Each correct answer presents a complete solution. Choose two.
A. The queries would perform better if the index named AccountNumber included the Name and QueryTime column.
B. The queries would perform worse if the index named AccountNumber included the NameColumn.
C. The queries would perform better if the index named AccountNumber included the Name column.
D. The object Account is a table, with an index having a leading column of AccountNumber and a Clustered Index named PKAccount.
E. The object Account is an indexed view, with an index having a leading column of AccountNumber and a Clustered Index named PKAccount.
F. The object Account is a view, joining the Account-AccountNumber and Account.PKAccount objects together.
Answer: B,D
Q7. You use SQL Server 2014 to maintain the data used by applications at your company. You need to run two separate SQL statements.
You must guarantee that the following three things happen:
1.
Either BOTH statements succeed or BOTH statements fail as a batch.
2.
If an error occurs on the first statement, SQL should not attempt to run the second statement.
3.
Error information should be returned to the client.
What should you do?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: A
Explanation: * SET XACT_ABORT When SET XACT_ABORT is ON, if a Transact-SQL statement raises a run-time error, the entire transaction is terminated and rolled back. When SET XACT_ABORT is OFF, in some cases only the Transact-SQL statement that raised the error is rolled back and the transaction continues processing.
Q8. You need to ensure that if any of the statements in usp_UpdateSpeakerName return an error message, all of the changes executed by usp_UpdateSpeakerName are not committed to the database.
What should you do in Procedures.sql? (Each correct answer presents part of the solution. Choose all that apply.)
A. Option A
B. Option B
C. Option C
D. Option D
E. Option E
Answer: B,D
Q9. Your network contains a server that has SQL Server 2014 installed. You create a table by using the following script:
You need to recommend a solution to ensure that each combination of ProductName and ProductManufacturer is not duplicated.
What should you recommend creating?
A. A UNIQUE constraint
B. A filtered index
C. A columnstore index
D. A CHECK constraint
Answer: A
Q10. You need to create the InvoiceStatus table in DB1.
How should you define the InvoiceID column in the CREATE TABLE statement?
A. Option A
B. Option B
C. Option C
D. Option D
Answer: C
Q11. You need to implement a solution that meets the data recovery requirements. You update each stored procedure to accept a parameter named @transactionID. What should you add next to the beginning of each stored procedure?
A. SAVE TRANSACTION WITH MARK @transactionID
B. ROLLBACK DISTRIBUTED TRANSACTION @transactionID
C. BEGIN TRANSACTION WITH MARK @transactionID
D. COMMIT TRANSACTION @transactionID
Answer: C
Q12. You need to add a new column named Confirmed to the Attendees table.
The solution must meet the following requirements:
. Have a default value of false.
. Minimize the amount of disk space used.
Which code block should you use?
A. ALTER TABLE Attendees
ADD Confirmed bit DEFAULT 0;
B. ALTER TABLE Attendees
ADD Confirmed char(l) DEFAULT '1'
C. ALTER TABLE Attendees
ADD Confirmed bit DEFAULT 1;
D. ALTER TABLE Attendees
ADD Confirmed char(l) DEFAULT ‘1’;
Answer: A
Explanation:
http://msdn.microsoft.com/en-us/library/ms177603.aspx
Q13. Topic 8)
You plan to deploy two stored procedures name USP_1 and USP_2 that read data from a database.
Your company identifies the following requirements for each stored procedure:
. USP_1 cannot allow dirty reads.
. USP_2 must place range locks on the data to ensure read consistency.
You need to identify which isolation level you must set for each stored procedure. The solution must minimize the number of locks.
Which isolation level should you identify?
To answer, drag the appropriate isolation level to the correct stored procedure in the answer area. (Answer choices may be used once, more than once, or not at all.)
Answer:
Q14. You have a Microsoft SQL Azure database that contains a table named Employees.
You create a non-clustered index named EmployeeName on the name column.
You write the following query to retrieve all of the employees that have a name that starts
with the letters JOH:
You discover that the query performs a table scan.
You need to ensure that the query uses EmployeeName.
What should you do?
A. Recreate EmployeeName as a unique index
B. Recreate EmployeeName as a clustered index
C. Replace LEFT(name,3) = 'JOH' by using name like 'JOH%'
D. Replace LEFT(name,3) = 'JOH' by using substring(name, 1, 3) = 'JOH'
Answer: C
Q15. Which data type should you use for ProductType?
A. varchar(11)
B. nvarchar(11)
C. char(11)
D. bigint
Answer: C
Topic 5, Litware, Inc
Overview
General Overview
You are a database developer for a company named Litware, Inc. Litware has a main office in Miami.
Litware has a job posting web application named WebApp1. WebApp1 uses a database named DB1. DB1 is hosted on a server named Server1. The database design of DB1 is shown in the exhibit. (Click the Exhibit button.)
WebApp1 allows a user to log on as a job poster or a job seeker. Candidates can search for job openings based on keywords, apply to an opening, view their application, and load their resume in Microsoft Word format. Companies can add a job opening, view the list of candidates who applied to an opening, and mark an application as denied.
Users and Roles
DB1 has five database users named Company, CompanyWeb, Candidate, CandidateWeb, and Administrator.
DB1 has three user-defined database roles. The roles are configured as shown in the following table.
Keyword Search
The keyword searches for the job openings are performed by using the following stored procedure named usp_GetOpenings:
Opening Update
Updates to the Openings table are performed by using the following stored procedure named usp_UpdateOpening:
Problems and Reported Issues
Concurrency Problems
You discover that deadlocks frequently occur.
You identify that a stored procedure named usp_AcceptCandidate and a stored procedure named usp_UpdateCandidate generate deadlocks. The following is the code for usp_AcceptCandidate:
Salary Query Issues
Users report that when they perform a search for job openings without specifying a minimum salary, only job openings that specify a minimum salary are displayed.
Log File Growth Issues
The current log file for DB1 grows constantly. The log file fails to shrink even when the daily SQL Server Agent Shrink Database task runs.
Performance Issues
You discover that a stored procedure named usp_ExportOpenings takes a long time to run and executes a table scan when it runs.
You also discover that the usp_GetOpenings stored procedure takes a long time to run and that the non-clustered index on the Description column is not being used.
Page Split Issues
On DB1, many page splits per second spike every few minutes.
Requirements
Security and Application Requirements
Litware identifies the following security and application requirements: . Only the Administrator, Company, and CompanyWeb database users must be able to execute the usp_UpdateOpening stored procedure. . Changes made to the database must not affect WebApp1.
Locking Requirements
Litware identifies the following locking requirements: . The usp_GetOpenings stored procedure must not be blocked by the usp_UpdateOpening stored procedure. . If a row is locked in the Openings table, usp_GetOpenings must retrieve the latest
version of the row, even if the row was not committed yet.
Integration Requirements
Litware exports its job openings to an external company as XML data. The XML data uses the following format:
A stored procedure named usp_ExportOpenings will be used to generate the XML data. The following is the code for usp_ExportOpenings:
The stored procedure will be executed by a SQL Server Integration Services (SSIS) package named Package1.
The XML data will be written to a secured folder named Folder1. Only a dedicated Active Directory account named Account1 is assigned the permissions to read from or write to Folder1.
Refactoring Requirements
Litware identifies the following refactoring requirements: . New code must be written by reusing the following query:
. The results from the query must be able to be joined to other queries.
Upload Requirements
Litware requires users to upload their job experience in a Word file by using WebApp1. WebApp1 will send the Word file to DB1 as a stream of bytes. DB1 will then convert the Word file to text before the contents of the Word file is saved to the Candidates table.
A database developer creates an assembly named Conversions that contains the following:
. A class named Convert in the SqlConversions namespace
. A method named ConvertToText in the Convert class that converts Word files to
text
The ConvertToText method accepts a stream of bytes and returns text. The method is used in the following stored procedure:
Job Application Requirements
A candidate can only apply to each job opening once.
Data Recovery Requirements
All changes to the database are performed by using stored procedures. WebApp1 generates a unique transaction ID for every stored procedure call that the application makes to the database.
If a server fails, you must be able to restore data to a specified transaction.
Q16. You need to monitor the health of your tables and indexes in order to implement the required index maintenance strategy.
What should you do?
A. Query system DMVs to monitor avg_chain_length and max_chain_length. Create alerts to notify you when these values converge.
B. Create a SQL Agent alert when the File Table: Avg time per file I/O request value is increasing.
C. Query system DMVs to monitor total_bucket_count. Create alerts to notify you when this value increases.
D. Query system DMVs to monitor total_bucket_count. Create alerts to notify you when this value decreases.
Answer: A
Explanation: From scenario:
*
You need to anticipate when POSTransaction table will need index maintenance.
*
The index maintenance strategy for the UserActivity table must provide the optimal structure for both maintainability and query performance.
Q17. You execute IndexManagement.sql and you receive the following error message: "Msg 512, Level 16, State 1, Line 12
Subquery returned more than 1 value. This is not permitted when the subquery follows =, != ,<, <= , >, > = or when the subquery is used as an expression."
You need to ensure that IndexManagement.sql executes properly.
Which WHILE statement should you use at line 18?
A. WHILE SUM(@RowNumber) < (SELECT @counter FROM @indextable)
B. WHILE @counter < (SELECT SUM(RowNumber) FROM @indextable)
C. WHILE COUNT(@RowNumber) < (SELECT @counter FROM @indextable)
D. WHILE @counter < (SELECT COUNT(RowNumber) FROM @indextable)
Answer: D