Defensive Database Programming with SQL Server


Defensive Database Programming with SQL Server
Defensive Database Programming with SQL Server
Open Access

Book Details

Author Alex Kuznetsov
Publisher Red Gate
Published 2010
Edition 1st
Paperback 389 pages
Language English
ISBN-13 9781906434458
ISBN-10 190643445X
License Open Access

Book Description

Resilient T-SQL code is code that is designed to last, and to be safely reused by others. The goal of defensive database programming, the goal of this book, is to help you to produce resilient T-SQL code that robustly and gracefully handles cases of unintended use, and is resilient to common changes to the database environment.

Too often as developers, we stop work as soon as our code passes a few basic tests to confirm that it produces the 'right result' in a given use case. We do not stop to consider what other possible ways in which the code might be used in the future, or how our code will respond to common changes to the database environment, such as a change in the database language setting, or a change to the nullability of a table column, and so on.

In the short-term, this approach is attractive; we get things done faster. However, if our code is designed to be used for more than just a few months, then it is very likely that such changes can and will occur, and the inevitable result is broken code or, even worse, code that silently starts to behave differently, or produce different results. When this happens, the integrity of our data is threatened, as is the validity of the reports on which critical business decisions are often based. At this point, months or years later, and long after the original developer has left, begins the painstaking process of troubleshooting and fixing the problem.

Would it not be easier to prevent all this troubleshooting from happening? Would it not be better to spend a little more time and effort during original development, to save considerably more time on troubleshooting, bug fixing, retesting, and redeploying?

This is what defensive programming is all about: we learn what can go wrong with our code, and we proactively apply this knowledge during development. This book is filled with practical, realistic examples of the sorts of problems that beset database programs, including:
- Changes in database objects, such as tables, constraints, columns, and stored procedures
- Changes to concurrency and isolation levels
- Upgrades to new versions of SQL Server
- Changes in requirements
- Code reuse
- Problems causing loss of data integrity
- Problems with error handling in T-SQL

In each case, it demonstrates approaches that will help you understand and enforce (or eliminate) the assumptions on which your solution is based, and to improve its robustness. Ultimately, the book teaches you how to think and develop defensively, and how to proactively identify and eliminate potential vulnerabilities in T-SQL code.


This book is published as open-access, which means it is freely available to read, download, and share without restrictions.

If you enjoyed the book and would like to support the author, you can purchase a printed copy (hardcover or paperback) from official retailers.

Download and Read Links

PDF

Share this Book

[localhost]# find . -name "*Similar_Books*"


Data Science with Microsoft SQL Server 2016

SQL R

R is one of the most popular, powerful data analytics languages and environments in use by data scientists. Actionable business data is often stored in Relational Database Management Systems (RDBMS), and one of the most widely used RDBMS is Microsoft SQL Server. Much more than a database server, it's a rich ecostructure with advanced analytic capab

SQL Server Hardware

SQL

SQL Server Hardware will provide the fundamental knowledge and resources you need to make intelligent decisions about choice, and optimal installation and configuration, of SQL Server hardware, operating system and the SQL Server RDBMS. Relational databases place heavy demands on their underlying hardware and many of these databases are mission-cri

SQL Server Backup and Restore

SQL

In this book, you'll discover how to perform each of these backup and restore operations using SQL Server Management Studio (SSMS), basic T-SQL scripts and Redgate's SQL Backup tool. Capturing backups using SSMS or simple scripts is perfectly fine for one-off backup operations, but any backups that form part of the recovery strategy for any given d

Protecting SQL Server Data

SQL

In Protecting SQL Server Data, John Magnabosco demonstrates how sensitive data, stored in SQL Server, can be protected using an efficient and maintainable encryption-based data architecture. He explains how to assess and categorize data elements according to sensitivity, regulate access to the various categories of data using database roles, views

SQL Server Execution Plans, 3rd Edition

SQL

If a query is performing poorly, and you can't understand why, then that query's execution plan will tell you not only what data set is coming back, but also what SQL Server did, and in what order, to get that data. It will reveal how the data was retrieved, and from which tables and indexes, what types of joins were used, at what point filtering,

Introducing Microsoft SQL Server 2016

SQL

Build your database management knowledge with the technical open book, Introducing SQL Server 2016. Get an overview of the SQL Server 2016 features - from in-memory performance and enhanced security to end-to-end mobile business intelligence and advanced analytics. - Learn about faster queries, improved security, higher availability, and state-of-t