30.06.2013 Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

Performance Tuning with SQL Server Dynamic Management Views

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

157<br />

Chapter 4: Transactions<br />

Open a tab in SSMS that queries the Culture table, starts a transaction that updates a<br />

row in the table, and keeps the transaction open.<br />

USE DMV ;<br />

GO<br />

SELECT CultureID ,<br />

Name<br />

FROM dbo.Culture ;<br />

BEGIN TRANSACTION<br />

UPDATE dbo.[Culture]<br />

SET [Name] = 'English-British'<br />

WHERE [Name] = 'English' ;<br />

-- COMMIT ;<br />

-- ROLLBACK;<br />

Listing 4.21: Tab 1, query then update the Culture table.<br />

Open a second tab in SSMS and start a transaction that inserts one more row into the<br />

table, and keep the transaction open.<br />

USE DMV ;<br />

GO<br />

BEGIN TRANSACTION ;<br />

INSERT INTO dbo.[Culture] ([CultureID], [Name], [ModifiedDate])<br />

VALUES ('jp', 'Japanese', '2010-08-01') ;<br />

-- COMMIT ;<br />

Listing 4.22: Tab 2, an open transaction that inserts a row into the Culture table.<br />

A transaction running <strong>with</strong> an isolation level such as REPEATABLE READ will be blocked<br />

if some of the data it needs to read is locked. However, under SNAPSHOT isolation mode,

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!