Data Quality Audit Query Suite
Generates a battery of SQL checks to surface nulls, duplicates, referential breaks, and anomalies in a table.
Prompt
ROLE: You are a data quality engineer who writes assertion-style checks before data is trusted. CONTEXT: Audit the table [TABLE_NAME] with schema [SCHEMA]. Business rules it should obey: [BUSINESS_RULES] (e.g., amount >= 0, status in a known set, one row per order). Related tables for referential checks: [RELATED_TABLES]. Engine: [DATABASE_ENGINE]. TASK: 1. Generate checks across these dimensions: completeness (NULLs in required fields), uniqueness (primary key dupes), validity (range/enum/format), consistency (cross-field rules), referential integrity (orphan foreign keys), freshness (max timestamp recency), and volume (row-count anomaly vs prior period). 2. For each check, write a SQL query that returns 0 rows when healthy and the offending rows/counts when not. 3. Assign a severity (block / warn / info) to each check. 4. Recommend which checks belong in CI vs scheduled monitoring. OUTPUT FORMAT: Check catalog table [Check | Dimension | Severity] -> One ```sql``` per check (labeled) -> Where to run each. CONSTRAINTS: Each check must be unambiguous: zero rows = pass. Avoid SELECT *; return only keys and the failing values. Make thresholds parameters, not magic numbers. Note any check that requires a baseline/prior snapshot to evaluate.
How to use this prompt
- 1
Copy the prompt above and paste it into ChatGPT, Claude, or Gemini — or open it in the visual Studio to edit each part on a canvas and run it with your own key.
- 2
Replace any bracketed placeholders with your specifics. The more concrete your context and constraints, the sharper the result — see the 5-part prompt structure.
- 3
Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.
Techniques in this prompt
Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.
Learn this techniqueIncludes worked examples so the model matches your format and quality by pattern, not description.
Learn this techniquePins the response to a defined structure so it drops straight into your workflow.
Learn this techniqueRecommended models
Build on this prompt
Open it in the visual Studio to wire it into a full workflow with your own API key — or learn the craft behind prompts like this.
More in Data Analysis & SQL
Translate Business Questions Into SQL
Turns a plain-English stakeholder question into a correct, well-commented SQL query against a known schema.
Optimize A Slow SQL Query
Diagnoses why a query is slow and rewrites it with targeted, explained optimizations and an index plan.
Debug A SQL Query That Returns Wrong Results
Systematically finds the logic error producing incorrect numbers and delivers a corrected, verified query.
Explain An Unfamiliar SQL Query In Plain English
Reverse-engineers a complex inherited query into a clear narrative, business meaning, and risk list.