22-25 April 2026

Unit Testing & Code Style: Enhancing Database Code Quality with SQLCop and tSQLt

Proposed session for SQLBits 2026

TL; DR

Dev's do it all the time, yet they 'mock' at the database level. This session goes over what we should all know, testing is important. It uses tSQLt and SQLCop as examples of t-sql based code that can be used to tests inside the database, and cover scenarios the 'set-up' from .NET code may not be able to test

Session Details

In today's fast-paced development environment, ensuring the quality of your code is crucial. When it comes to databases, maintaining consistency and accuracy can be especially challenging. In this session, we will explore how to use SQLCop and tSQLt to improve database code quality and enhance your .NET development process.

We'll start by introducing the basics of SQLCop, a set of T-SQL Procedures for analyzing code style and best practices in SQL Server databases.

Next, we'll dive into the world of unit testing, including the benefits of writing tests, best practices for test design, and the tSQLt testing frameworks for SQL Server.

We'll also explore how to integrate database unit tests and code quality checks into your CI/CD processes. Though ask your DevOps team how they can be used with Pull Requests to block 'bad code'

Whether you're a beginner or an experienced data professional, this session will provide valuable insights for improving the quality of your database code.

3 things you'll get out of this session

Understand why testing is needed Look at options to test in the database, independent of .NET tests CI/CD integrations, blocking Code merges when tests fail