Detecting Locks Objective: Detect locks from the Query Editor in SQL Server Management Studio Open a...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Detecting Locks Objective: Detect locks from the Query Editor in SQL Server Management Studio Open a word document and add appropriate screenshots for each of the steps below and add appropriate documentation for each step as needed. Deliverables - Documented word document with screenshots and script files. 1. Connect to current Microsoft SQL Server instance through the Database Engine in SQL Server Management Studio. 2. (10 points) In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: SET IMPLICIT TRANSACTIONS ON BEGIN TRANSACTION UPDATE Adventure Works.Human Resources. Employee WITH (XLOCK, TABLOCK) SET NationalID Number = 222222223 WHERE BusinessEntityID = 1; 3. Click the Execute button in toolbar and you would see the following message in the output: 1 row affected. IMPLICIT TRANSACTIONS is set to ON in the query to prevent the DB engine from auto committing the update. 4. (10 points) You will now create a SQL query that attempts to read from the same table that you used in Step 2. In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: SELECT * FROM AdventureWorks.Human Resources.Employee; 5. Click the Execute button in toolbar and you would see that this transaction does not complete and the status bar at the bottom of the window shows the transaction status as Executing query. The query will continue to execute while it waits for the lock on the table that you caused during Step 2 to be released. 6. (10 points] Having caused the blocking lock, you will now troubleshoot the problem using the sp who2 procedure. In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: EXECUTE sp who2; 7. (10 points) Click the Execute button in the toolbar. Scroll through the result set until you see a value in the column named BikBy. Make a note of the process ID in the SPID column. This process, the SELECT query that you executed in Step 4, is being blocked by the uncommitted update process that you executed in Step2. 8. (10 points) You have now identified the process ID of the problematic query that is causing the blocking lock. However, you do not know which lock(s) are causing the process to be blocked. In the current Query editor window, delete the previous command and type the following command: EXECUTE sp lock; 9. Click the Execute button in the tool bar. The procedure lists all the locks on logical resources on database instance. You should make a note of the object and the database IDs of the exclusive table lock in your query results as the IDs may differ from example. 10.(10 points) Using the database and object IDs, you can now locate the database and the table with the exclusive lock. In the current query editor window, delete the previous command and type the following command, substituting the values for object id and database_id that you noted in Step 9. SELECT name, type dese FROM sys.objects WHERE object id="JOBJECT_ID]"; SELECT name FROM sys.databases WHERE database_id "[DATABASE_ID]"; 11.(10 points) Click the Execute button in the toolbar. The returned result sets should list AdventureWorks database and the Employee USER TABLE as the table with the exclusive lock. 12. (10 points) Click the tab of the Query Editor window that you used to create the exclusive lock in Step 2. Delete the previous command and then type the following command in the query editor window: COMMIT TRANSACTION; 13. (10 points) Click the Execute button on the toolbar. Committing transaction updates, the table and causes the database engine to release the exclusive lock. Click the tab of the Query editor window that you used to create the SELECT query in Step 4. You should now see that this query has successfully executed and that it includes the updated NationalIDNumber in the result set. 14.(10 points] Delete the query text and type the following command in the Query editor window: EXECUTE sp who2; 15. Click the Execute button in the toolbar. Scan the BlkBy column and verify that there are no longer any blocking processes. Close the open Query editor tabs and complete the activity. Detecting Locks Objective: Detect locks from the Query Editor in SQL Server Management Studio Open a word document and add appropriate screenshots for each of the steps below and add appropriate documentation for each step as needed. Deliverables - Documented word document with screenshots and script files. 1. Connect to current Microsoft SQL Server instance through the Database Engine in SQL Server Management Studio. 2. (10 points) In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: SET IMPLICIT TRANSACTIONS ON BEGIN TRANSACTION UPDATE Adventure Works.Human Resources. Employee WITH (XLOCK, TABLOCK) SET NationalID Number = 222222223 WHERE BusinessEntityID = 1; 3. Click the Execute button in toolbar and you would see the following message in the output: 1 row affected. IMPLICIT TRANSACTIONS is set to ON in the query to prevent the DB engine from auto committing the update. 4. (10 points) You will now create a SQL query that attempts to read from the same table that you used in Step 2. In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: SELECT * FROM AdventureWorks.Human Resources.Employee; 5. Click the Execute button in toolbar and you would see that this transaction does not complete and the status bar at the bottom of the window shows the transaction status as Executing query. The query will continue to execute while it waits for the lock on the table that you caused during Step 2 to be released. 6. (10 points] Having caused the blocking lock, you will now troubleshoot the problem using the sp who2 procedure. In the SQL Server Management studio, click the New Query toolbar to open new query editor window and type the following query: EXECUTE sp who2; 7. (10 points) Click the Execute button in the toolbar. Scroll through the result set until you see a value in the column named BikBy. Make a note of the process ID in the SPID column. This process, the SELECT query that you executed in Step 4, is being blocked by the uncommitted update process that you executed in Step2. 8. (10 points) You have now identified the process ID of the problematic query that is causing the blocking lock. However, you do not know which lock(s) are causing the process to be blocked. In the current Query editor window, delete the previous command and type the following command: EXECUTE sp lock; 9. Click the Execute button in the tool bar. The procedure lists all the locks on logical resources on database instance. You should make a note of the object and the database IDs of the exclusive table lock in your query results as the IDs may differ from example. 10.(10 points) Using the database and object IDs, you can now locate the database and the table with the exclusive lock. In the current query editor window, delete the previous command and type the following command, substituting the values for object id and database_id that you noted in Step 9. SELECT name, type dese FROM sys.objects WHERE object id="JOBJECT_ID]"; SELECT name FROM sys.databases WHERE database_id "[DATABASE_ID]"; 11.(10 points) Click the Execute button in the toolbar. The returned result sets should list AdventureWorks database and the Employee USER TABLE as the table with the exclusive lock. 12. (10 points) Click the tab of the Query Editor window that you used to create the exclusive lock in Step 2. Delete the previous command and then type the following command in the query editor window: COMMIT TRANSACTION; 13. (10 points) Click the Execute button on the toolbar. Committing transaction updates, the table and causes the database engine to release the exclusive lock. Click the tab of the Query editor window that you used to create the SELECT query in Step 4. You should now see that this query has successfully executed and that it includes the updated NationalIDNumber in the result set. 14.(10 points] Delete the query text and type the following command in the Query editor window: EXECUTE sp who2; 15. Click the Execute button in the toolbar. Scan the BlkBy column and verify that there are no longer any blocking processes. Close the open Query editor tabs and complete the activity.
Expert Answer:
Related Book For
Database Processing Fundamentals, Design, and Implementation
ISBN: 978-0133876703
14th edition
Authors: David M. Kroenke, David J. Auer
Posted Date:
Students also viewed these databases questions
-
To demonstrate the ability to propose, implement, and query the database. Problem: MovinOn Inc. is a moving company that provides moving and storage services in California, Nevada, and Arizona....
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Ebrahim Patel is a wholesaler who uses the periodic inventory system to account for inventory. Transactions for February: 1 Bought inventory from Rich Traders for R5 000 on credit. 2 Sold inventory...
-
The National Health Statistics Reports dated Oct. 22, 2008, included the following information on the heights (in.) for non-Hispanic white females: a. Calculate and interpret a confidence interval at...
-
You have a portfolio with a beta of 1.35. What will be the new portfolio beta if you keep 85 percent of your money in the old portfolio and 5 percent in a stock with a beta of 0.78
-
Analyze the roles that art can play in politics. Give examples of the use of art to promote political ends.
-
Mason Paper Company (MPC) manufactures commodity grade papers for use in computer printers and photocopiers. MPC has reported net operating losses for the last two years due to intense price pressure...
-
Sunland Company is considering an investment that will return a lump sum of $770,000 6 years from now. Click here to view the factor table. What amount should Sunland Company pay for this investment...
-
The case of Michigan Basic Property Insurance Association v. Washington (MICHIGAN BASIC PROPERTY INSURANCE ASSOCIATION V. JOYCE WASHINGTON, CLEVELAND POWELL, COUNTRYWIDE HOME LOANS, DIMONTI &...
-
Wikitekkee purchased supplies costing $4,000 and records the entire purchase as supplies expense on January 1, 2021. On December 31, 2021, the company have unused supplies of $2,000. Which one of the...
-
Corporate bond A has a 6 percent coupon and matures in 3 years. Corporate bond B has a 6 percent coupon and matures in 15 years. The current interest rate is 6 percent. By how much will Bond A and...
-
Assume a bond matures in 6 years with a par value of $1,000, and annual coupon payment of $80, as well as a market interest rate of 9%. What is the bond's price?
-
Big Corp is planning to fully acquire Small Corp. Big Corp currently has 10 million shares outstanding with a share price of $50 and total outstanding debt of $100 million (no excess cash). Small...
-
A firm's current balance sheet is as follows: Assets $ 120 Debt $ 12 Equity $ 108 A. What is the firm's weighted-average cost of capital at various combinations of debt and equity, given the...
-
Allison, age 40, earns $81,915 annually; her wage replacement ratio has been determined to be 73%. She expects inflation will average 3% over her entire life expectancy. She expects to work until 67...
-
Due to a coffee glut, the price per pound of coffee fell: 2018 Price per pound $8.00 Quantity demanded (pounds) 4.0 million pounds 2019 $7.00 4.7 million pounds a. Calculate the price elasticity of...
-
Find the area of the surface generated by revolving the para- metric curve x = cos 1, y = sin? 1 (0 < I sa/2) about the y-axis.
-
Why is the choice of the primary key important?
-
In general, how can you transform a relation not in BCNF into ones that are in BCNF?
-
Explain how the two tables you provided in Review Question 1.6 are related. Which table contains the foreign key, and what it is the foreign key?
-
Describe the process of valuing the entrepreneurs ownership interest in a two-stage investment. Refer to Tables 13.10 and 13.13. Data from table 13.10 Data from table 13.13 Market potential...
-
Euro Exchange Rates. The exchange rate that we consider is the amount of euros that one can purchase for one U.S. dollar. We have \(T=699\) daily observations from the period April 1, 2005, through...
-
Evaluate the current yield curve level and structure using the following screens: a. YCRV or GC to access yield curves. b. FWCV to determine implied forward rates. c. USoo03M, USoo06M, USoo09M, and...
Study smarter with the SolutionInn App