Lab Answer Key for Module 11: Managing Transactions and Locks



Similar documents
Lab Answer Key for Module 6: Configuring and Managing Windows SharePoint Services 3.0. Table of Contents Lab 1: Configuring and Managing WSS 3.

Lab Answer Key for Module 9: Active Directory Domain Services. Table of Contents Lab 1: Exploring Active Directory Domain Services 1

Pipeliner CRM Phaenomena Guide Sales Pipeline Management Pipelinersales Inc.

Pipeliner CRM Phaenomena Guide Add-In for MS Outlook Pipelinersales Inc.

Pipeliner CRM Phaenomena Guide Opportunity Management Pipelinersales Inc.

Lab Answer Key for Module 1: Installing and Configuring Windows Server Table of Contents Lab 1: Configuring Windows Server

Pipeliner CRM Phaenomena Guide Administration & Setup Pipelinersales Inc.

Pipeliner CRM Phaenomena Guide Getting Started with Pipeliner Pipelinersales Inc.

Pipeliner CRM Phaenomena Guide Sales Target Tracking Pipelinersales Inc.

Overview of Microsoft Office 365 Development

Lab 02 Working with Data Quality Services in SQL Server 2014

UPGRADE. Upgrading Microsoft Dynamics Entrepreneur to Microsoft Dynamics NAV. Microsoft Dynamics Entrepreneur Solution.

Management Reporter Integration Guide for Microsoft Dynamics GP

Introduction to Hyper-V High- Availability with Failover Clustering

Windows Small Business Server 2003 Upgrade Best Practices

BizTalk Server Business Activity Monitoring. Microsoft Corporation Published: April Abstract

Module 1: Introduction to Designing Security

The 2007 R2 Version of Microsoft Office Communicator Mobile for Windows Mobile: Frequently Asked Questions

Deploying the Workspace Application for Microsoft SharePoint Online

Implementing and Supporting Windows Intune

How To Set Up A Virtual Pc Classroom Setup Guide For A Student Computer Course

How To Configure A Windows 8.1 On A Windows (Windows) With A Powerpoint (Windows 8) On A Blackberry) On An Ipad Or Ipad (Windows 7) On Your Blackberry Or Black

Creating and Deploying Active Directory Rights Management Services Templates Step-by-Step Guide

Management Reporter Integration Guide for Microsoft Dynamics AX

Pipeliner CRM Phaenomena Guide Importing Leads & Opportunities Pipelinersales Inc.

Office Language Interface Pack for Farsi (Persian) Content

Hands-On Lab: WSUS. Lab Manual Expediting WSUS Service for XP Embedded OS

Update and Installation Guide for Microsoft Management Reporter 2.0 Feature Pack 1

How To Use A Microsoft Microsoft Database Server 2012

Technical Brief for Windows Home Server Remote Access

How To Set Up A Load Balancer With Windows 2010 Outlook 2010 On A Server With A Webmux On A Windows Vista V (Windows V2) On A Network With A Server (Windows) On

Module 8: Implementing Group Policy

Using Apple Remote Desktop to Deploy Centrify DirectControl

EventTracker: Support to Non English Systems

Integrating Business Portal 3.0 with Microsoft Office SharePoint Portal Server 2003: A Natural Fit

RedBlack CyBake Online Customer Service Desk

Windows Server 2012 R2 Remote Apps Publishing within the enterprise and beyond

Windows SharePoint Services Installation Guide

Improving Performance of Microsoft CRM 3.0 by Using a Dedicated Report Server

Writers: Joanne Hodgins, Omri Bahat, Morgan Oslake, and Matt Hollingsworth

Enable File and Folder Auditing

4.0. Offline Folder Wizard. User Guide

SQL Server 2014 BI. Lab 04. Enhancing an E-Commerce Web Application with Analysis Services Data Mining in SQL Server Jump to the Lab Overview

SQL Server 2005 Reporting Services (SSRS)

Integrate Microsoft Windows Hyper V

All other trademarks are property of their respective owners.

Customizing Remote Desktop Web Access by Using Windows SharePoint Services Stepby-Step

Microsoft Lync Server 2010

Microsoft Dynamics GP. SmartList Builder User s Guide With Excel Report Builder

CRM to Exchange Synchronization

Microsoft Business Solutions Navision 4.0 Development I C/SIDE Introduction Virtual PC Setup Guide. Course Number: 8359B

Deploying Remote Desktop IP Virtualization Step-by-Step Guide

How To Install Outlook Addin On A 32 Bit Computer

Windows Azure Pack Installation and Initial Configuration

Deep Dive into SharePoint Provider Hosted Apps

Exclaimer Alias Manager for Exchange Deployment Guide - Exclaimer Alias Manager for Exchange Outlook Add-In

20487B: Developing Windows Azure and Web Services

How to Secure a Groove Manager Web Site

CRM to Exchange Synchronization

AD RMS Step-by-Step Guide

Hyper-V Server 2008 Getting Started Guide

Windows Server Update Services 3.0 SP2 Step By Step Guide

Integrating Symantec Endpoint Protection

Microsoft Dynamics CRM 4.0 User s Guide

Implementing and Supporting Windows Intune

Windows BitLocker Drive Encryption Step-by-Step Guide

Deploying Personal Virtual Desktops by Using RemoteApp and Desktop Connection Step-by-Step Guide

Installing Windows Rights Management Services with Service Pack 2 Step-by- Step Guide

User Guide. Live Meeting. MailStreet Live Support:

Checking System Requirements. How-To Guide

Managing Linux Servers with System Center 2012 R2

Windows Scheduled Tasks Management Pack Guide for System Center Operations Manager. Published: 07 March 2013

Deciding When to Deploy Microsoft Windows SharePoint Services and Microsoft Office SharePoint Portal Server White Paper

Migrating Active Directory to Windows Server 2012 R2

Microsoft Corporation. Status: Preliminary documentation

2.0. Quick Start Guide

CRM to Exchange Synchronization

Step-by-Step Guide for Monitoring in Windows HPC Server 2008 Beta 2

Microsoft Office Communicator 2007 Getting Started Guide. Published: July 2007

Introduction to Unified Device Management with Intune and System Center Configuration Manager

Hyper-V Server 2008 Setup and Configuration Tool Guide

Deploying Remote Desktop Web Access with Remote Desktop Connection Broker Step-by- Step Guide

Step-by-Step Guide for Microsoft Advanced Group Policy Management 4.0

Product Development. Using Critical Path EVM for the Microsoft Project Desktop Application Readme

Business Portal for Microsoft Dynamics GP. Project Time and Expense Administrator s Guide Release 10.0

Adobe Acrobat 9 Deployment on Microsoft Systems Management

Sage HRMS 2014 Sage Employee Self Service Tech Installation Guide for Windows 2003, 2008, and October 2013

Redeploying Microsoft CRM 3.0

Active Directory Provider User s Guide

Module 3: Implementing an Organizational Unit Structure

Webmetrics Web Monitoring Getting Started Guide

File and Printer Sharing with Microsoft Windows

Microsoft Dynamics GP. Payroll Connect

MicrosoftDynam ics GP TenantServices Installation and Adm inistration Guide

Microsoft Solutions for Security. Delivering the Windows Server 2003 Security Guide

Microsoft Dynamics AX 2009 Installation Guide. Microsoft Corporation Published: November 2009

Microsoft Dynamics GP. Pay Steps for Human Resources Release 9.0

AvePoint Record Rollback for Microsoft Dynamics CRM. Release Notes

Transcription:

Lab Answer Key for Module 11: Managing Transactions and Locks Table of Contents Lab 11: Managing Transactions and Locks 1 Exercise 1: Using Transactions 1 Exercise 2: Managing Locks 3

Information in this document, including URL and other Internet Web site references, is subject to change without notice. Unless otherwise noted, the example companies, organizations, products, domain names, e- mail addresses, logos, people, places, and events depicted herein are fictitious, and no association with any real company, organization, product, domain name, e-mail address, logo, person, place, or event is intended or should be inferred. Complying with all applicable copyright laws is the responsibility of the user. Without limiting the rights under copyright, no part of this document may be reproduced, stored in or introduced into a retrieval system, or transmitted in any form or by any means (electronic, mechanical, photocopying, recording, or otherwise), or for any purpose, without the express written permission of Microsoft Corporation. The names of manufacturers, products, or URLs are provided for informational purposes only and Microsoft makes no representations and warranties, either expressed, implied, or statutory, regarding these manufacturers or the use of the products with any Microsoft technologies. The inclusion of a manufacturer or product does not imply endorsement of Microsoft of the manufacturer or product. Links are provided to third party sites. Such sites are not under the control of Microsoft and Microsoft is not responsible for the contents of any linked site or any link contained in a linked site, or any changes or updates to such sites. Microsoft is not responsible for webcasting or any other form of transmission received from any linked site. Microsoft is providing these links to you only as a convenience, and the inclusion of any link does not imply endorsement of Microsoft of the site or the products contained therein. Microsoft may have patents, patent applications, trademarks, copyrights, or other intellectual property rights covering subject matter in this document. Except as expressly provided in any written license agreement from Microsoft, the furnishing of this document does not give you any license to these patents, trademarks, copyrights, or other intellectual property. 2007 Microsoft Corporation. All rights reserved. Microsoft, BizTalk, Internet Explorer, Jscript, MSDN, Outlook, PowerPoint, SQL Server, Visual Basic, Visual C#, Visual C++, Visual FoxPro, Visual Studio, Windows and Windows Server are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries. The names of actual companies and products mentioned herein may be the trademarks of their respective owners. Version 1.0

Lab Answer Key for Module 11: Managing Transactions and Locks 1 Lab 11: Managing Transactions and Locks Exercise 1: Using Transactions Task 1: Create and commit a transaction 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio. 2. In the Connect to Server dialog box, specify the values in the following table, and then click Connect. Server type Database Engine 3. On the File menu, point to Open, and then click File. Windows 4. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click Tran1.sql, 5. In the Connect to Database Engine dialog box, specify the values in the following Windows Notice that the statements update a record in the Person.Contact table. The SELECT statements and the @@trancount global variable are used to show the progress of the transaction. 6. Locate the comment START TRANSACTION HERE, and then add a statement to start a transaction. Your code should resemble the following. BEGIN TRANSACTION 7. Click Execute to execute the script, and then review the results. At this point, the transaction is still active and locks are still held. The changes made have not been committed to the database. 8. Locate the comment END TRANSACTION HERE, and then add a statement to commit the changes to the database. Your code should resemble the following. COMMIT TRANSACTION 9. Select the end transaction statement, and then click Execute. The changes are now committed to the database. 10. Select the last two statements in the script, and then click Execute.

2 Lab Answer Key for Module 11: Managing Transactions and Locks 11. Verify that the transaction count is now set to zero and the changes have been committed to the database. 12. On the File menu, click Save Tran1.sql. 13. On the File menu, click Close. Task 2: Create and roll back a transaction 1. On the File menu, point to Open, and then click File. 2. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click Tran2.sql, 3. In the Connect to Database Engine dialog box, specify the values in the following Windows Notice that the statements update a different record in the Person.Contact table. Again, the SELECT statements and the @@trancount global variable show the progress of the transaction. 4. Locate the comment END TRANSACTION HERE, and then add a statement to roll back the changes to the database. Your code should resemble the following. ROLLBACK TRANSACTION 5. Click Execute to execute the script, and then review the results. Notice that the transaction is complete because the transaction count is zero and the changes have been cancelled. 6. On the File menu, click Save Tran2.sql. 7. Close SQL Server Management Studio.

Lab Answer Key for Module 11: Managing Transactions and Locks 3 Exercise 2: Managing Locks Task 1: View locking information 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio. 2. In the Connect to Server dialog box, specify the values in the following table, and then click Connect. Server type Database Engine Windows 3. In SQL Server Management Studio, in the console tree, expand, expand Management, right-click Activity Monitor, and then click View Processes. 4. Review the information that is displayed in Process Info, Locks by Process, and Locks by Object. 5. Close Activity Monitor. 6. On the File menu, point to New, and then click Query with Current Connection. 7. Type the following statement into the query window. SELECT resource_type, request_mode, request_type, request_status, request_session_id FROM sys.dm_tran_locks 8. Click Execute to execute the statement. 9. Review the information that shows the current lock in the master database. 10. On the File menu, point to Open, and then click File. 11. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click Lock1.sql, 12. In the Connect to Database Engine dialog box, specify the values in the following Windows Notice that a transaction starts with the BEGIN TRANSACTION statement, but there is no corresponding COMMIT TRANSACTION or ROLLBACK TRANSACTION statement to complete the transaction. 13. Click Execute to execute the script and note the SPID of the connection. 14. Switch back to the original query window and then click Execute to execute the query and retrieve data from the sys.dm_tran_locks view.

4 Lab Answer Key for Module 11: Managing Transactions and Locks Notice that now the SPID of the second connection holds locks on various objects. 15. In SQL Server Management Studio, in the console tree, expand, expand Management, right-click Activity Monitor, and then click View Processes. 16. Review the information that is now displayed for the new SPID in Process Info, Locks by Process, and Locks by Object. 17. Close Activity Monitor. 18. Switch to the Lock1.sql query window, type the following code at the end of the script, and then execute the statement. ROLLBACK TRANSACTION 19. Switch back to the original query window, and then click Execute to execute the query and retrieve data from the sys.dm_tran_locks view. Notice that the object locks acquired during the transaction have now been released. 20. Close SQL Server Management Studio without saving the changes to the files. Task 2: Set locking options 1. Click Start, point to All Programs, point to Microsoft SQL Server 2005, and then click SQL Server Management Studio. 2. In the Connect to Server dialog box, specify the values in the following table, and then click Connect. Server type Database Engine 3. On the File menu, point to Open, and then click File. Windows 4. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click Lock1.sql, 5. In the Connect to Database Engine dialog box, specify the values in the following Windows 6. Review the contents of the file, and then execute the query. 7. On the File menu, point to Open, and then click File. 8. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click Lock2.sql,

Lab Answer Key for Module 11: Managing Transactions and Locks 5 9. In the Connect to Database Engine dialog box, specify the values in the following Windows 10. Review the contents of the file and notice that the transaction isolation level is set to SERIALIZABLE, which prevents other users from accessing rows that match the criteria in a WHERE clause. Note: In the next step, you will execute the query. Continue with the exercise and do not wait for the execution to complete. 11. Click Execute to execute the query. 12. On the File menu, point to Open, and then click File. 13. In the Open File dialog box, browse to the D:\Labfiles\Starter folder, click LockList.sql, 14. In the Connect to Database Engine dialog box, specify the values in the following Windows 15. Click Execute to execute the query and notice that there is an entry of WAIT in the request_status column, which indicates that the second query is waiting for a lock to be granted before proceeding. 16. Switch to the Lock2.sql query window, and then click Cancel Executing Query. 17. Switch to the LockList.sql query window, and then click Execute to execute the query. 18. Verify that the waiting transaction has been cancelled. Task 3: Set the lock timeout 1. Switch to the Lock2.sql query window, and then edit the file by adding the following statement immediately before the BEGIN TRANSACTION statement. SET lock_timeout 5000 2. Click Execute to execute the query and wait five seconds. Notice that the query no longer waits indefinitely for the lock to be granted. 3. Close SQL Server Management Studio without saving the changes to the files.