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
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 tsql.run command to execute any of these tests.
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
CLR
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
SMO and DMO
SQL Server Agent Service
xp cmdshell
Buffer cache hit ratio
Page life expectancy