Skip to content
tSQLt tests to highlight potential problems in your database
TSQL PowerShell PLpgSQL
Branch: master
Clone or download
RobClenshaw Merge pull request #12 from red-gate/fixes
Filter out SQLCop tests from the Invalid Objects test
Latest commit a20ad40 Dec 9, 2019


Welcome to the SQL Cop repository!

These are a set of tSQLt tests designed to allow you to detect common problems in your database, originally maintained by George Mastros on LessThanDot.

This project is now managed by SQLServerCentral and Redgate Software. Steve Jones is the primary contact, but all updates and contributions are welcome by pull request. If you submit a contribution, please include reasons why the changes are helpful to most users of the project.


This project requires the tsqlt framework to run the tests. All SQL Server versions that support the SQLCLR can use these tests. Please check the tsqlt requirements for your system.

NOTE : These Tests are NOT suitable for production databases

Installing the tests

All tests are created a stored procedures in a test class (schema), called SQLCop. You can compile them in a SQL Server database and use the command to execute any of these tests.

Issues Checked

The following is a list of issues that are checked by the current project.


Procedures with SP_
VarChar Size Problems
Decimal Size Problem
Undocumented Procedures
Procedures without SET NOCOUNT ON
Procedures with SET ROWCOUNT
Procedures with @@Identity
Procedures with dynamic sql
Procedures using dynamic sql without sp_executesql


Column Name Problems
Columns with float data type
Columns with image data type
Tables with text/ntext
Collation Mismatch
UniqueIdentifier with NewId


Table Prefix
Table Name Problems
Missing Foreign Keys
Wide Tables
Tables without a primary key
Empty Tables
Views with order by
Unnamed Constraints


Fragmented indexes
Missing Foreign Key Indexes
Forwarded Records


Database Collation
Auto Close
Auto Create
Auto Shrink
Auto Update
Compatibility Level
Login Language
Old Backups
Orphaned Users
User Aliases
Ad Hoc Distributed Queries
Database and log files on the same physical disk
Database Mail
Deprecated Features
Instant File Initialization
Max Degree of Parallelism
OLE Automation Procedures
Service Account
SQL Server Agent Service
xp cmdshell


Buffer cache hit ratio
Page life expectancy
You can’t perform that action at this time.