Matt Lacey
Matt Lacey

Reputation: 65564

Tool for validating SQL Server database schema

Are there any tools available for validating a database schema against a set of design rules, naming conventions, etc.

I'm not talking about comparing one database to another (as covered by this question).

I want to be able to say "What in this database doesn't meet this set of rules".

Some examples of the type of rules I'm talking about would be like:
- Primary key fields should be the first in the table.
- Foreign keys should have an index on that field.
- Field names ending 'xxx' should be of a certain type.
- Fields with a constraint limiting it it certain values it should have a default.

I've written a bunch of scripts to do this in the past and was wondering if there was something generic available.

Ideally I'd like something for SQL Server, but if you're aware of something for other databases it may be useful to know about them too.

Upvotes: 4

Views: 4947

Answers (2)

John
John

Reputation: 360

A tool called SQLCop is doing what your asking for, but I don't believe it actually allows you to write rules yourself.

http://sqlcop.lessthandot.com/detectedissues.php

Upvotes: 1

Mitch Wheat
Mitch Wheat

Reputation: 300499

One way to accomplish this would be to script out an entire database and then apply rules consisting of regular expressions to the script. SSW's commercial tool does something similiar for SQL Server.

Upvotes: 1

Related Questions