{"id":110346,"date":"2026-05-08T08:55:32","date_gmt":"2026-05-08T08:55:32","guid":{"rendered":"https:\/\/www.red-gate.com\/simple-talk\/?post_type=collection&#038;p=110346"},"modified":"2026-05-08T08:55:33","modified_gmt":"2026-05-08T08:55:33","slug":"t-sql-coding-basics","status":"publish","type":"collection","link":"https:\/\/www.red-gate.com\/simple-talk\/collections\/t-sql-coding-basics\/","title":{"rendered":"T-SQL Coding Basics"},"content":{"rendered":"\n<p>In this series, <strong>Robert Sheldon<\/strong> introduces you to the basics of working with T-SQL, covering such topics as readability, accuracy, performance, standardization, and other factors. The series in not intended as a prescriptive how-to list that dictates what approaches you should take, but rather as a set of guidelines for evaluating the types of issues you should address when coming up with your own approach to T-SQL coding.<\/p>\n\n\n\n<section id=\"articles-list-block_8cea8d2d6f3b7b3b0d6959221ea6b90f\" class=\"articles-list my-5xl\">\n    <div class=\"grid gap-3xl\">\n        <div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-4-performance\/\" aria-label=\"The Basics of Good T-SQL Coding Style \u2013 Part 4: Performance\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">T-SQL Programming<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/robert-sheldon\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/06\/Robert-Sheldon.jpg\"\n            alt=\"Image of author: Robert Sheldon\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Robert Sheldon<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/\">\n                            T-SQL Programming                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-4-performance\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            The Basics of Good T-SQL Coding Style \u2013 Part 4: Performance        <\/h1>\n                    <p class=\"mb-0\">\n                There are several obvious problems with poor SQL Coding habits. It can make code difficult to maintain, or can confuse&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>31 July 2017<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>17 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n<div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-3-querying-manipulating-data\/\" aria-label=\"The Basics of Good T-SQL Coding Style &#8211; Part 3: Querying and Manipulating Data\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">T-SQL Programming<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/robert-sheldon\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/06\/Robert-Sheldon.jpg\"\n            alt=\"Image of author: Robert Sheldon\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Robert Sheldon<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/\">\n                            T-SQL Programming                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-3-querying-manipulating-data\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            The Basics of Good T-SQL Coding Style &#8211; Part 3: Querying and Manipulating Data        <\/h1>\n                    <p class=\"mb-0\">\n                SQL was designed to be a third-generation language, expressed in syntax close to real language, because it was designed to&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>27 June 2017<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>17 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n<div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-2-defining-database-objects\/\" aria-label=\"The Basics of Good T-SQL Coding Style &#8211; Part 2: Defining Database Objects\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">T-SQL Programming<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/robert-sheldon\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/06\/Robert-Sheldon.jpg\"\n            alt=\"Image of author: Robert Sheldon\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Robert Sheldon<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/\">\n                            T-SQL Programming                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style-part-2-defining-database-objects\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            The Basics of Good T-SQL Coding Style &#8211; Part 2: Defining Database Objects        <\/h1>\n                    <p class=\"mb-0\">\n                Technical debt is a real problem in database development, where corners have been cut in the rush to keep to&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>02 June 2017<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>22 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n<div class=\"@container\">\n    <article class=\"flex gap-2xl items-center flex-col @md:flex-row-reverse\">\n        <div class=\"w-full @md:w-1\/3 flex items-center justify-center peer\">\n            <a href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style\/\" aria-label=\"The Basics of Good T-SQL Coding Style\" class=\"no-underline relative aspect-3\/2 bg-gray-100 border border-gray-100 dark:border-gray-800 flex items-center justify-center flex-col gap-md w-full p-md\">\n\t\t\t\t\t\t\t\t\t\t\t\t\t<span class=\"font-display-slab text-2xl text-base-black text-center w-full hyphens-auto\">T-SQL Programming<\/span>\n\t\t\t\t\t\t\t\t\t\t\t<img loading=\"lazy\" decoding=\"async\" class=\"w-24\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/themes\/simple-talk-theme-2024\/assets\/images\/logos\/st-logo.svg\" alt=\"Simple-Talk Logo\" width=\"153\" height=\"33\">\n\t\t\t<\/a>        <\/div>\n        <div class=\"w-full @md:w-2\/3 overflow-auto group\/content-text\">\n            \n<div class=\"block mb-md align-middle\">\n            \n        <a\n        href=\"https:\/\/www.red-gate.com\/simple-talk\/author\/robert-sheldon\/\"\n        class=\"group\/author inline align-middle no-style min-w-fit\"\n        rel=\"author\"\n    >\n        <img decoding=\"async\" src=\"https:\/\/www.red-gate.com\/simple-talk\/wp-content\/uploads\/2018\/06\/Robert-Sheldon.jpg\"\n            alt=\"Image of author: Robert Sheldon\" \n            class=\"rounded-full align-middle w-6 h-6 duration-200 inline-block object-cover\"\/>\n        <span class=\"group-hover\/author:text-brand-600 peer\/ftr-image:text-brand-600 group-hover\/author:dark:text-brand-400 peer\/ftr-image:dark:text-brand-400 group-hover\/author:underline min-w-fit align-middle duration-200\">Robert Sheldon<\/span>\n    <\/a>\n\n        <span class=\"card__categories align-middle\">\n                                                        <span class=\"text-gray-600 align-middle dark:text-gray-400\">in<\/span>\n                    <a\n                    class=\"inline align-middle no-underline hover:text-brand-600 hover:dark:text-brand-400 hover:underline\"\n                    href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/\">\n                            T-SQL Programming                    <\/a>\n                                        <\/span>\n<\/div>\n<a class=\"no-underline group\/content-text-lower\" href=\"https:\/\/www.red-gate.com\/simple-talk\/databases\/sql-server\/t-sql-programming-sql-server\/basics-good-t-sql-coding-style\/ \">\n    <div>\n        <h1 class=\"\n            duration-200 mt-0 mb-1 text-xl\n            \n            peer-hover:group-[]\/content-text:text-brand-600\n            group-hover\/content-text-lower:text-brand-600\n\n            peer-hover:group-[]\/content-text:dark:text-brand-400\n            group-hover\/content-text-lower:dark:text-brand-400\n            \n            peer-hover:group-[]\/content-text:underline\n            group-hover\/content-text-lower:underline\n            \n        \">\n            The Basics of Good T-SQL Coding Style        <\/h1>\n                    <p class=\"mb-0\">\n                TSQL Code must work properly and efficiently. That&#8217;s not enough though. Unless you are working alone, have perfect memory and&#8230;            <\/p>\n            <\/div>\n            <div class=\"flex items-center gap-1 mt-md\">\n            <time>05 May 2017<\/time>\n            <span class=\"w-1 h-1 bg-current\tinline-block my-auto rounded-full\"><\/span>\n            <span>20 min read<\/span>\n                    <\/div>\n    <\/a>        <\/div>\n    <\/article>\n<\/div>\n\n\n            <\/div>\n<\/section>\n","protected":false},"excerpt":{"rendered":"<p>In this series, Robert Sheldon introduces you to the basics of working with T-SQL, covering such topics as readability, accuracy, performance, standardization, and other factors. The series in not intended as a prescriptive how-to list that dictates what approaches you should take, but rather as a set of guidelines for evaluating the types of issues&#8230;&hellip;<\/p>\n","protected":false},"author":221841,"featured_media":0,"template":"","tags":[159388],"coauthors":[6779],"class_list":["post-110346","collection","type-collection","status-publish","hentry","tag-the-basics-of-good-t-sql-coding"],"acf":[],"_links":{"self":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/collection\/110346","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/collection"}],"about":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/types\/collection"}],"author":[{"embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/users\/221841"}],"wp:attachment":[{"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/media?parent=110346"}],"wp:term":[{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/tags?post=110346"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.red-gate.com\/simple-talk\/wp-json\/wp\/v2\/coauthors?post=110346"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}