Top‑Down Multi‑Server Database Count Workflow (POC)

A simple, non-intrusive metadata pipeline designed to map an entire database estate and track schema drift across server environments.

⭐ Why Hierarchical Asset Discovery Is a Best Practice

Taking a top-down approach to mapping database infrastructure delivers immediate benefits to the administration team:

Onboarding Purpose: As a new DBA onboarding here, the goal is simple: get an immediate handle on total database counts, asset sizes, and code drift across all environments. This script pipeline lets you automatically discover hidden SQL instances, query their inner schemas, and pass that raw data to an off-server Python pipeline that tidies everything up into a clean, executive-ready Excel sheet.

🚦 Execution Order & Pipeline Architecture

The workflow uses three basic files to securely discover infrastructure metadata, gather granular object logs, and format data locally.

1 Script A: The Topography Mapper

Reads the registry on your host machines to find every single installed SQL instance—especially those hidden or undocumented named instances that nobody told you about.

📄 File Created: 1_Master_Topology_Map.csv — Maps out which physical host machines match up with which SQL engines.

Why it matters: You use this clean list to piece together your connection strings so you know exactly where to point your queries in Step 2.

*Quick Tip: If a high-security network blocks Script A from reading the registry, just skip it and paste your known instance connections straight into the start array of Script B.

2 Script B: Granular Object & Schema Counter

Logs into each SQL Engine discovered in Step 1, loops through every user database, maps the schemas, and counts your stored procedures.

📄 File Created: 2_SQL_Topology_Summary.csv — Gives you a high-level table count and procedure count per instance to gauge the scale of a server at a fast glance.

📄 File Created: 3_SQL_Granular_Object_Inventory.csv — Your master flat dataset containing schema names, object names, table row counts, and creation/modification dates.

Why it matters: This is where you play detective. If an object hasn't been touched since 2018 and lives in a [Backup] schema, it's immediate dead weight to delete. If a staging table has 0 rows but was modified last night, it's part of an active midnight job—don't touch it!

3 Script C: Python Analytics Pipeline

Pure SQL outputs flat text grids. Python acts as our report designer. It reads that giant raw file into an ultra-fast in-memory matrix (a DataFrame), handles the cross-server math, and formats it beautifully.

📄 File Created: SQL_Infrastructure_Report.xlsx — Smashes through the server isolation barriers to combine all your separate server counts side-by-side into one page—all without using slow, messy production Linked Servers.

Why it matters: It automatically applies an executive "Steel Blue" styling template with clean fonts (Segoe UI), gridlines, and perfect number alignments. It even features a Decommission Targets tab where you can run a disk usage report to show management exactly how many gigabytes of physical hardware storage you are about to save the company!

📊 Expected Outcome: Final Dynamic Drift Sheet

This is the clean, side-by-side view your Python code spits out. It makes pipeline version alignments or unexpected changes stand out immediately.

Database Name Schema Name VA-DB-PROD01 (Prod) VA-DB-STAGE01 (Stage) VA-DB-TEST01 (Test) VA-DB-DEV01 (Dev) Simple Status / What to Check
VA-PORTAL dbo 350 350 350 362 +12 Procs: Active local developer changes in Dev.
VA-PORTAL app 62 65 65 65 +3 Procs: New code packages ready and waiting for release.
VA-PORTAL stage 0 0 16 16 +16 Procs: Automated night-time ETL cleanup zones.
VA-CLAIMS dbo 185 185 185 185 In Sync: Safe and sound. Object counts match perfectly.
VA-BENEFITS dbo 94 94 94 94 In Sync: Clean match across all server levels.
← Back to Portfolio