Learn your way! Get started

SQL 2012 Developer, Part 04 of 13: Transactions

with expert Don Kiely

Watch trailer

Course at a glance

Included in these subscriptions:

  • Dev & IT Pro Video
  • Dev & IT Pro Power Pack

Release date 4/8/2013
Level Intermediate
Runtime 1h 37m
Closed captioning Included
Transcript Included
eBooks / courseware Included
Hands-on labs Included
Sample code Included
Exams Included

Enterprise Solutions

Need reporting, custom learning tracks, or SCORM? Learn More

Course description

In this course you’ll learn about transaction concepts and the ACID test that SQL Server uses to protect the integrity of data. You’ll also learn about locking and blocking, and how to avoid these inevitable effects of heavily used relational databases. You’ll see how to use transactions in applications, as well as how to handle compile and run time errors caused by your code. Then you’ll learn about how to take control of transactions and defined them explicitly in your code. Then we’ll wrap with a look at a relatively new feature of T-SQL, structured exception handling that has long been a feature of general purpose programming languages.


This course assumes that you have a basic familiarity with the concept of relational databases and a basic understanding of what SQL Server is and the high-level tools in it, as well as how to create and manage objects using Management Studio. You should also have a basic understanding of how SQL Server implements security, including its authentication and authorization schemes, and how to assign permissions on securable objects to principals. You should know the fundamentals of Transact-SQL to write queries to retrieve and update data, and how to execute scripts using the query editor in Management Studio. It will be very helpful, but not absolutely necessary, to have experience with .NET development using Visual Studio 2010 or 2012 for the portions of the course that deal with SQLCLR development. The .NET code included in this course is written in C#, but if you prefer Visual Basic it should be fairly easy to convert the code.

Learning Paths

This course is part of the following LearnNowOnline SuccessPaths™:
SQL Server Developer

Meet the expert

Don Kiely is a featured instructor on many of our SQL Server and Visual Studio courses. He is a nationally recognized author, instructor, and consultant specializing in Microsoft technologies. Don has many years of teaching experience, is the author or co-author of several programming books, and has spoken at many industry conferences and user groups. In addition, Don is a consultant for a variety of companies that develop distributed applications for public and private organizations.

Course outline


Transaction Concepts (30:20)
  • Introduction (01:32)
  • Passing the ACID Test (03:21)
  • Transactions Types (02:03)
  • Transaction Details (00:43)
  • Isolation Levels (05:36)
  • Locking (02:58)
  • Viewing Lock Information (00:55)
  • Avoiding Blocked Transactions (00:39)
  • Demo: Blocking (02:37)
  • Demo: Read Uncomitted (02:25)
  • Working Around DeadLocks (02:21)
  • Deadlocks (01:40)
  • Preventing Deadlocks (02:38)
  • Summary (00:47)
Applications and Transactions (13:17)
  • Introduction (00:32)
  • Designing Transaction Support (01:42)
  • Efficiency Guidelines (01:59)
  • Compile and Runtime Errors (01:07)
  • Demo: Compiler Errors (03:31)
  • Demo: Runtime Errors (02:25)
  • Demo:Invalid Object Name Error (01:20)
  • Summary (00:37)
Creating Explicit Transactions (28:36)
  • Introduction (01:02)
  • Explicit Transaction Syntax (01:56)
  • Nested Transactions (01:11)
  • Demo: @@TRANCOUNT (01:22)
  • Error Handling (01:31)
  • Using @@ERROR (00:54)
  • Demo: Error Handling (03:25)
  • Manage with Stored Procedures (02:07)
  • Demo: Proactive Checks (03:28)
  • Demo:Errors In Transaction (02:30)
  • Demo: Testing Stored Procedure (02:47)
  • Using RAISERROR (02:15)
  • Demo: Using RAISERROR (01:16)
  • Demo: User-Defined RAISERROR (02:20)
  • Summary (00:24)
Structured Error Handling (24:55)
  • Introduction (00:45)
  • TRY/CATCH Overview (00:38)
  • Demo: TRY/CATCH (02:06)
  • Error Chaining (01:17)
  • Errors Not Handled (00:56)
  • Error Handling Functions (01:19)
  • Demo: Error Handling Functions (01:39)
  • Using RAISERROR With TRY/CATCH (00:41)
  • Demo: RAISERROR With TRY/CATCH (02:08)
  • The THROW Statement (03:13)
  • Demo: Using THROW Statement (02:32)
  • Demo: Within Stored Procedure (03:03)
  • Uncommittable Transactions (01:04)
  • XACT_STATE Function (01:02)
  • Demo: XACT_STATE (01:44)
  • Summary (00:41)