{"id":905,"date":"2024-12-06T08:00:00","date_gmt":"2024-12-06T13:00:00","guid":{"rendered":"https:\/\/www.sqltabletalk.com\/?p=905"},"modified":"2024-12-02T12:50:53","modified_gmt":"2024-12-02T17:50:53","slug":"t-sql-error-handling-transaction-management-part-3","status":"publish","type":"post","link":"https:\/\/www.sqltabletalk.com\/?p=905","title":{"rendered":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management"},"content":{"rendered":"<h2>Introduction<\/h2>\n<p>Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional <code>IF<\/code> statements, loops, and <code>CASE<\/code> expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we&#8217;ll focus on two essential concepts for writing reliable SQL code: <strong>Error Handling with <code>TRY...CATCH<\/code> Blocks<\/strong> and <strong>Transaction Management<\/strong>.<\/p>\n<p>Imagine you&#8217;re running a script that updates multiple records, and an unexpected error occurs halfway through. Without proper error handling and transactions, you could end up with partial updates, leading to data inconsistencies. By understanding these concepts, you can ensure your scripts handle errors gracefully and maintain data integrity.<\/p>\n<h2>Error Handling with TRY&#8230;CATCH Blocks<\/h2>\n<h3>Understanding TRY&#8230;CATCH<\/h3>\n<p>In T-SQL, the <code>TRY...CATCH<\/code> construct allows you to handle runtime errors in a controlled manner. When an error occurs within the <code>TRY<\/code> block, control is transferred to the <code>CATCH<\/code> block, where you can define how to respond to the error\u2014whether it&#8217;s logging the issue, cleaning up resources, or notifying users.<\/p>\n<h3>Basic Structure<\/h3>\n<pre><code>BEGIN TRY\n    -- Statements that might cause an error\nEND TRY\nBEGIN CATCH\n    -- Statements to handle the error\nEND CATCH<\/code><\/pre>\n<h3>Practical Example<\/h3>\n<p>Let&#8217;s consider a simple scenario where we attempt to divide a number by zero, which will cause an error:<\/p>\n<pre><code>BEGIN TRY\n    DECLARE @Result INT;\n    SET @Result = 10 \/ 0; -- This will cause a divide-by-zero error\nEND TRY\nBEGIN CATCH\n    SELECT\n        ERROR_NUMBER() AS ErrorNumber,\n        ERROR_MESSAGE() AS ErrorMessage;\nEND CATCH;<\/code><\/pre>\n<h4>Explanation<\/h4>\n<ul>\n<li><strong>BEGIN TRY:<\/strong> We start the <code>TRY<\/code> block and perform an operation that causes an error (<code>10 \/ 0<\/code>).<\/li>\n<li><strong>BEGIN CATCH:<\/strong> When the error occurs, execution jumps to the <code>CATCH<\/code> block.<\/li>\n<li><strong>Error Functions:<\/strong> Inside the <code>CATCH<\/code> block, we use <code>ERROR_NUMBER()<\/code> and <code>ERROR_MESSAGE()<\/code> to retrieve details about the error.<\/li>\n<li><strong>Result:<\/strong> The error details are displayed, helping us understand what went wrong.<\/li>\n<\/ul>\n<h3>Why Use TRY&#8230;CATCH?<\/h3>\n<ul>\n<li><strong>Graceful Error Handling:<\/strong> Prevents abrupt script termination and allows for proper cleanup.<\/li>\n<li><strong>Error Information:<\/strong> Provides details about errors, aiding in debugging.<\/li>\n<li><strong>Maintain Control Flow:<\/strong> Allows the script to continue running or to exit gracefully.<\/li>\n<\/ul>\n<h2>Transaction Management in T-SQL<\/h2>\n<h3>Understanding Transactions<\/h3>\n<p>A transaction is a sequence of operations performed as a single unit of work. Transactions ensure that either all operations succeed or none do, maintaining data integrity. This is especially important when multiple related changes need to be made to the database.<\/p>\n<h3>Key Statements<\/h3>\n<ul>\n<li><strong>BEGIN TRANSACTION:<\/strong> Starts a new transaction.<\/li>\n<li><strong>COMMIT TRANSACTION:<\/strong> Saves all changes made during the transaction.<\/li>\n<li><strong>ROLLBACK TRANSACTION:<\/strong> Reverts all changes made during the transaction.<\/li>\n<\/ul>\n<h3>Practical Example<\/h3>\n<p>Suppose we want to transfer $100 from Account A to Account B. Both the debit and credit operations must succeed together.<\/p>\n<pre><code>BEGIN TRY\n    BEGIN TRANSACTION;\n    \n    -- Deduct $100 from Account A\n    UPDATE Accounts\n    SET Balance = Balance - 100\n    WHERE AccountID = 1;\n    \n    -- Add $100 to Account B\n    UPDATE Accounts\n    SET Balance = Balance + 100\n    WHERE AccountID = 2;\n    \n    -- Commit the transaction if both updates succeed\n    COMMIT TRANSACTION;\n    PRINT 'Transaction committed successfully.';\nEND TRY\nBEGIN CATCH\n    -- Roll back the transaction if an error occurs\n    ROLLBACK TRANSACTION;\n    PRINT 'Transaction rolled back due to an error.';\n    \n    -- Display error information\n    SELECT\n        ERROR_NUMBER() AS ErrorNumber,\n        ERROR_MESSAGE() AS ErrorMessage;\nEND CATCH;<\/code><\/pre>\n<h4>Explanation<\/h4>\n<ul>\n<li><strong>BEGIN TRANSACTION:<\/strong> Starts the transaction.<\/li>\n<li><strong>Updates:<\/strong> We perform two updates\u2014deducting from one account and adding to another.<\/li>\n<li><strong>COMMIT TRANSACTION:<\/strong> If both updates are successful, we commit the transaction.<\/li>\n<li><strong>Error Handling:<\/strong> If an error occurs, control moves to the <code>CATCH<\/code> block.\n<ul>\n<li><strong>ROLLBACK TRANSACTION:<\/strong> Reverts all changes made in the transaction.<\/li>\n<li><strong>Error Information:<\/strong> We display the error number and message.<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Why Use Transactions?<\/h3>\n<ul>\n<li><strong>Atomicity:<\/strong> Ensures all operations within the transaction are completed successfully or not at all.<\/li>\n<li><strong>Data Integrity:<\/strong> Maintains consistency in the database.<\/li>\n<li><strong>Error Recovery:<\/strong> Makes it easier to handle errors by rolling back incomplete operations.<\/li>\n<\/ul>\n<h2>Combining Error Handling and Transactions<\/h2>\n<p>By using <code>TRY...CATCH<\/code> blocks with transactions, you can ensure that your database operations are both robust and reliable.<\/p>\n<h3>Practical Example<\/h3>\n<p>Let&#8217;s modify the previous example to include error handling and transactions in a data import scenario.<\/p>\n<pre><code>BEGIN TRY\n    BEGIN TRANSACTION;\n    \n    -- Attempt to insert data\n    INSERT INTO Employees (Name, Position)\n    SELECT Name, Position\n    FROM NewEmployees;\n    \n    -- Commit the transaction if the insert succeeds\n    COMMIT TRANSACTION;\n    PRINT 'Data imported successfully.';\nEND TRY\nBEGIN CATCH\n    -- Roll back the transaction if an error occurs\n    ROLLBACK TRANSACTION;\n    PRINT 'Transaction rolled back due to an error.';\n    \n    -- Display error information\n    SELECT\n        ERROR_NUMBER() AS ErrorNumber,\n        ERROR_MESSAGE() AS ErrorMessage;\nEND CATCH;<\/code><\/pre>\n<h4>Explanation<\/h4>\n<ul>\n<li><strong>Data Import:<\/strong> We attempt to insert data from <code>NewEmployees<\/code> into <code>Employees<\/code>.<\/li>\n<li><strong>Transaction Management:<\/strong> The operation is enclosed within a transaction to ensure atomicity.<\/li>\n<li><strong>Error Handling:<\/strong> If any error occurs during the insert, we roll back the transaction.<\/li>\n<li><strong>Feedback:<\/strong> We provide messages indicating success or failure.<\/li>\n<\/ul>\n<h3>Benefits<\/h3>\n<ul>\n<li><strong>Consistency:<\/strong> Ensures that either all new employees are added or none are.<\/li>\n<li><strong>Error Awareness:<\/strong> Provides immediate feedback if something goes wrong.<\/li>\n<li><strong>Data Integrity:<\/strong> Prevents partial data imports that could corrupt the database.<\/li>\n<\/ul>\n<h2>Best Practices<\/h2>\n<h3>Keep Transactions Short<\/h3>\n<ul>\n<li><strong>Efficiency:<\/strong> Long transactions can lock resources and affect performance.<\/li>\n<li><strong>Responsiveness:<\/strong> Short transactions reduce wait times for other users.<\/li>\n<\/ul>\n<h3>Use Error Handling to Maintain Data Integrity<\/h3>\n<ul>\n<li><strong>Prevent Partial Updates:<\/strong> Roll back transactions when errors occur to avoid inconsistent data.<\/li>\n<li><strong>Inform Users:<\/strong> Provide clear messages to users or administrators when errors happen.<\/li>\n<\/ul>\n<h3>Test Your Error Handling Logic<\/h3>\n<ul>\n<li><strong>Simulate Errors:<\/strong> Intentionally cause errors during testing to ensure your <code>TRY...CATCH<\/code> blocks work as expected.<\/li>\n<li><strong>Review Error Messages:<\/strong> Make sure error messages are informative and helpful.<\/li>\n<\/ul>\n<h3>Avoid Unnecessary Complexity<\/h3>\n<ul>\n<li><strong>Simplify Scripts:<\/strong> Keep your error handling and transaction logic straightforward.<\/li>\n<li><strong>Focus on Essentials:<\/strong> Only include necessary code to manage transactions and handle errors.<\/li>\n<\/ul>\n<h2>Conclusion<\/h2>\n<p>In this installment, we&#8217;ve learned how to use <code>TRY...CATCH<\/code> blocks for error handling and how to manage transactions in T-SQL. These constructs are essential for writing robust SQL scripts that can handle unexpected situations gracefully and maintain data integrity.<\/p>\n<p>By incorporating proper error handling, you ensure that your scripts can respond to issues without crashing or leaving the database in an inconsistent state. Transactions allow you to group related operations so they either all succeed or fail together, which is important for maintaining consistency.<\/p>\n<p>As you continue to develop more complex SQL scripts, these tools will help you create reliable and maintainable code. They are fundamental skills for any SQL developer aiming to build professional and resilient database applications.<\/p>\n<p>In our next post, we&#8217;ll explore <strong>Common Table Expressions (CTEs)<\/strong> and <strong>Recursive Queries<\/strong>, which will expand your ability to write complex queries in T-SQL efficiently.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we&#8217;ll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY&#8230;CATCH Blocks and Transaction Management.<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[35,84,18,78,21],"tags":[407,229,404,408,348,131,344,405,406],"class_list":["post-905","post","type-post","status-publish","format-standard","hentry","category-data-integrity","category-sql-developer","category-transaction-logs","category-tsql","category-tutorial","tag-commit","tag-database-integrity","tag-error-handling","tag-rollback","tag-sql-scripting","tag-sql-server","tag-t-sql","tag-transactions","tag-try-catch"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk<\/title>\n<meta name=\"description\" content=\"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we&#039;ll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.sqltabletalk.com\/?p=905\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk\" \/>\n<meta property=\"og:description\" content=\"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we&#039;ll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.sqltabletalk.com\/?p=905\" \/>\n<meta property=\"og:site_name\" content=\"SQL Table Talk\" \/>\n<meta property=\"article:published_time\" content=\"2024-12-06T13:00:00+00:00\" \/>\n<meta name=\"author\" content=\"Stephen Planck\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Stephen Planck\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"4 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905\"},\"author\":{\"name\":\"Stephen Planck\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\"},\"headline\":\"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management\",\"datePublished\":\"2024-12-06T13:00:00+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905\"},\"wordCount\":850,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\"},\"keywords\":[\"COMMIT\",\"Database Integrity\",\"Error Handling\",\"ROLLBACK\",\"SQL Scripting\",\"SQL Server\",\"T-SQL\",\"Transactions\",\"TRY...CATCH\"],\"articleSection\":[\"Data Integrity\",\"SQL Developer\",\"Transaction Logs\",\"TSQL\",\"Tutorial\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.sqltabletalk.com\/?p=905#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905\",\"url\":\"https:\/\/www.sqltabletalk.com\/?p=905\",\"name\":\"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk\",\"isPartOf\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#website\"},\"datePublished\":\"2024-12-06T13:00:00+00:00\",\"description\":\"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we'll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.sqltabletalk.com\/?p=905\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.sqltabletalk.com\/?p=905#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.sqltabletalk.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#website\",\"url\":\"https:\/\/www.sqltabletalk.com\/\",\"name\":\"SQL Table Talk\",\"description\":\"Breaking Down SQL Server, One Post at a Time.\",\"publisher\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.sqltabletalk.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0\",\"name\":\"Stephen Planck\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g\",\"caption\":\"Stephen Planck\"},\"logo\":{\"@id\":\"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/\"},\"sameAs\":[\"https:\/\/dexterwiki.com\",\"https:\/\/www.linkedin.com\/in\/stephen-planck-4611b692?trk=people-guest_people_search-card&challengeId=AQErf8gbBmcVMwAAAYsyIsxO-0UvU8z7cHrBpZoo_n3xt9qEKpRN5B_jd_LmAMu-OfeArkQ7GDjobJ2uRoQQV35EQdh_rR6kxA&submissionId=09de7067-c335-8e17-40b8-8dc32b60ed6c&challengeSource=AgEcUCw35zpPmAAAAYsyI4vAWhJTV7Nt4vZYKc3V1qiDBpCkKgUvtlOBgYXcE84&challegeType=AgE_wZiTT09IAQAAAYsyI4vDmNvbZIYe6XHju5V2bXVvM3IVxnJslgY&memberId=AgESFTkUShzs_gAAAYsyI4vGYk0Gic1uc5kB6cKOABA26Gw&recognizeDevice=AgHdSZyUSI5CEwAAAYsyI4vKd_koF9JgpsCJShT8QfbK1QMiv8SI\",\"https:\/\/www.youtube.com\/linuxmate\"],\"url\":\"https:\/\/www.sqltabletalk.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk","description":"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we'll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.sqltabletalk.com\/?p=905","og_locale":"en_US","og_type":"article","og_title":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk","og_description":"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we'll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.","og_url":"https:\/\/www.sqltabletalk.com\/?p=905","og_site_name":"SQL Table Talk","article_published_time":"2024-12-06T13:00:00+00:00","author":"Stephen Planck","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Stephen Planck","Est. reading time":"4 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.sqltabletalk.com\/?p=905#article","isPartOf":{"@id":"https:\/\/www.sqltabletalk.com\/?p=905"},"author":{"name":"Stephen Planck","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0"},"headline":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management","datePublished":"2024-12-06T13:00:00+00:00","mainEntityOfPage":{"@id":"https:\/\/www.sqltabletalk.com\/?p=905"},"wordCount":850,"commentCount":0,"publisher":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0"},"keywords":["COMMIT","Database Integrity","Error Handling","ROLLBACK","SQL Scripting","SQL Server","T-SQL","Transactions","TRY...CATCH"],"articleSection":["Data Integrity","SQL Developer","Transaction Logs","TSQL","Tutorial"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.sqltabletalk.com\/?p=905#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.sqltabletalk.com\/?p=905","url":"https:\/\/www.sqltabletalk.com\/?p=905","name":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management - SQL Table Talk","isPartOf":{"@id":"https:\/\/www.sqltabletalk.com\/#website"},"datePublished":"2024-12-06T13:00:00+00:00","description":"Welcome back to our series on programming constructs in T-SQL! In the previous installments, we explored variables, conditional IF statements, loops, and CASE expressions. These tools have helped us write dynamic and efficient SQL scripts. In this third part, we'll focus on two essential concepts for writing reliable SQL code: Error Handling with TRY...CATCH Blocks and Transaction Management.","breadcrumb":{"@id":"https:\/\/www.sqltabletalk.com\/?p=905#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.sqltabletalk.com\/?p=905"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.sqltabletalk.com\/?p=905#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.sqltabletalk.com\/"},{"@type":"ListItem","position":2,"name":"Exploring Programming Constructs in T-SQL \u2013 Part 3: Error Handling and Transaction Management"}]},{"@type":"WebSite","@id":"https:\/\/www.sqltabletalk.com\/#website","url":"https:\/\/www.sqltabletalk.com\/","name":"SQL Table Talk","description":"Breaking Down SQL Server, One Post at a Time.","publisher":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.sqltabletalk.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":["Person","Organization"],"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/1947e42a9438bccd91691d8b791888e0","name":"Stephen Planck","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/64181114edc3de3d99072c049bcec024f025c9536dc89fc8ff1bac58976ca81e?s=96&d=mm&r=g","caption":"Stephen Planck"},"logo":{"@id":"https:\/\/www.sqltabletalk.com\/#\/schema\/person\/image\/"},"sameAs":["https:\/\/dexterwiki.com","https:\/\/www.linkedin.com\/in\/stephen-planck-4611b692?trk=people-guest_people_search-card&challengeId=AQErf8gbBmcVMwAAAYsyIsxO-0UvU8z7cHrBpZoo_n3xt9qEKpRN5B_jd_LmAMu-OfeArkQ7GDjobJ2uRoQQV35EQdh_rR6kxA&submissionId=09de7067-c335-8e17-40b8-8dc32b60ed6c&challengeSource=AgEcUCw35zpPmAAAAYsyI4vAWhJTV7Nt4vZYKc3V1qiDBpCkKgUvtlOBgYXcE84&challegeType=AgE_wZiTT09IAQAAAYsyI4vDmNvbZIYe6XHju5V2bXVvM3IVxnJslgY&memberId=AgESFTkUShzs_gAAAYsyI4vGYk0Gic1uc5kB6cKOABA26Gw&recognizeDevice=AgHdSZyUSI5CEwAAAYsyI4vKd_koF9JgpsCJShT8QfbK1QMiv8SI","https:\/\/www.youtube.com\/linuxmate"],"url":"https:\/\/www.sqltabletalk.com\/?author=1"}]}},"jetpack_featured_media_url":"","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/905","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=905"}],"version-history":[{"count":1,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/905\/revisions"}],"predecessor-version":[{"id":906,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=\/wp\/v2\/posts\/905\/revisions\/906"}],"wp:attachment":[{"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=905"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=905"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.sqltabletalk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=905"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}