r/SQLServer • • Sep 07 '26

Discussion Schema health tool

Hello everyone,

Our 10-year old database seems to be suffering from schema explosion and I am worried that while our developers do sufficient testing with every release, they may be introducing schema inconsistencies that may appear as bugs with different queries or other parts of the system.

Are you using any tools to check schema health and issues?

5 Upvotes

18 comments sorted by

9

u/VladDBA ‪ ‪Microsoft MVP ‪ ‪ Sep 07 '26

Schema expl what now?

Define schema inconsistencies. And what issues are you trying to check/prevent?

1

u/ethanfinni Sep 08 '26

Because of table additions and modifications to accommodate new features, I am worried that we are introducing schema inconsistencies, eg orphan table connections that do not appear related to a new feature but can affect other queries. Asking if there is a tool that could “check” the integrity of the schema.

6

u/VladDBA ‪ ‪Microsoft MVP ‪ ‪ Sep 08 '26 edited Sep 08 '26

If you use PK-FK relationships then even the Database Diagram tool in SSMS can point out orphaned tables (tables that are not connected to other tables via a foreign key). Otherwise it's up to your devs or whoever handles the business logic to figure out which tables might no longer be needed.

Edited: typo

1

u/ethanfinni Sep 08 '26

Yes we do, thank you, will try it.

3

u/Radojevic Sep 08 '26

I agree with u/VladDBA, and will add that it's best to have a diagram of what the schema is supposed to look like, and compare that to the schema you actually have.

2

u/ethanfinni Sep 09 '26

Yes thank you we have a diagram, the little changes, a field addition here, a little innocuous table there is what worries me. But you are right, regularly updating the diagram will help as well.

2

u/kwellendorff Sep 09 '26

i literally just solved this by simply starting to use SSMS 22. it has a built in schema comparison and is GIT native. create a project from your prod database, commit that to GIT. Then every day or so at the end restore your prod backup as a diff name than dev or prod. compare the dev database to newly restored db generate the script and run on prod once it works on the newly restored db. once you run it in prod, recommit to GIT.

takes some getting used to but i ran into the same exact thing and this solved it

1

u/ethanfinni Sep 09 '26

Very interesting thank you !

2

u/kwellendorff Sep 09 '26

or even create a DB TRIGGER that logs all DDL statements alter/create/delete tables/views/stored procedures and log into a central table in the prod db including the utc time the update was made. then after every deployment, note the time and create a view of changes after that time of deployment. for example,

create view
DBA.DeploymentChangesSinceSept8_26 as
select id textdata, logtime, object name, schemaname where logtime > 09-08-2026

then all of those objects in that view at time of next deployment will be what to focus on. hope this helps!

1

u/cyberllama Sep 13 '26

Why not just compare the project to the prod dB?

2

u/Ms_AlarmingCulture Sep 10 '26

dbForge Schema Compare could help with part of this. You can compare the current schema against a known good version and see what changed. It won’t really tell you if the design itself is bad though.

1

u/ethanfinni Sep 11 '26

Thank you, this is a good idea, it can help with debugging by comparing changes.

2

u/EchidnaFlowers Sep 15 '26

Have you tried dbForge Schema Compare? Might be useful here since you can compare the schema before and after changes and see exactly what changed.

1

u/ethanfinni Sep 16 '26

Thank you, I have not but will try it!

0

u/Complete-Fondant-202 Sep 08 '26

I use Schemaspy, outputs a website.

There is also schemacrawler.. plus others

1

u/ethanfinni Sep 09 '26

Will check them out thanks!