Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FxCop for SQL Server - Tool to analyze SQL Server databases for potential issues

Is there a tool out there that can analyse SQL Server databases for potential problems?

For example:

  • a foreign key column that is not indexed
  • an index on a uniqueidentifier column that has no FILL FACTOR
  • a LastModifiedDate DATETIME column that has no UPDATE trigger to update the datetime
  • a large index with "high" fragmentation
  • a non-fragmented index that exists in multiple extents
  • a trigger that does not contain SET NOCOUNT ON (leaving it suspectible to "A trigger returned a resultset and/or was running with SET NOCOUNT OFF while another outstanding result set was active.")
  • a database, table, stored procedure, trigger, view, created with SET ANSI_NULLS OFF
  • a database or table with SET ANSI_PADDING OFF
  • a database or table created with SET CONCAT_NULL_YIELDS_NULL OFF
  • a highly fragmented index that might benefit from a lower FILLFACTOR (i.e. more padding)
  • a table with a very wide clustered index (e.g. uniqueidentifier+uniqueidentifier)
  • a table with a non-unique clustered index
  • use of text/ntext rather than varchar(max)/nvarchar(max)
  • use of varchar in columns that could likely contain localized strings and should be nvarchar (e.g. Name, FirstName, LastName, BusinessName, CountryName, City)
  • use of *=, =*, *=* rather than LEFT OUTER JOIN, RIGHT OUTER JOIN, FULL OUTER JOIN
  • trigger that returns a results set
  • any column declared as timestamp rather than rowversion
  • a nullable timestamp column
  • use of image rather than varbinary(max)
  • databases not in simple mode (or a log file more than 100x the size of the data file)

Is there an FxCop for SQL Server?

Note: The Microsoft SQL Server 2008 R2 Best Practices Analyzer doesn't fit the bill.

like image 925
Ian Boyd Avatar asked Jan 19 '12 15:01

Ian Boyd


People also ask

What are SQL Server tools?

SQL Server Data Tools (SSDT) A modern development tool for building SQL Server relational databases, Azure SQL databases, Analysis Services (AS) data models, Integration Services (IS) packages, and Reporting Services (RS) reports.

What is the purpose of index in SQL Server?

An index contains keys built from one or more columns in the table or view. These keys are stored in a structure (B-tree) that enables SQL Server to find the row or rows associated with the key values quickly and efficiently.

What is a sequel database?

A SQL database is a collection of tables that stores a specific set of structured data. The SQL database has long been the tried and true workhorse of the backend enterprise and at the heart of everything we do in this electronic age.


2 Answers

There's SQLCop - free, and quite an interesting tool, too!

enter image description here

like image 101
marc_s Avatar answered Oct 06 '22 00:10

marc_s


There is a tool called Static Code Analysis (not exactly a great name given its collision with VS-integrated FxCop) that is included with Visual Studio Premium and Ultimate that can cover at least the design-time subset of your rules. You can also add your own rules if the in-box rule set doesn't do everything you want.

like image 38
Nicole Calinoiu Avatar answered Oct 05 '22 23:10

Nicole Calinoiu