Data Analysis & SQL5.0 · 0 ratings

Data Quality Audit Query Suite

Generates a battery of SQL checks to surface nulls, duplicates, referential breaks, and anomalies in a table.

Role-BasedFew-ShotStructured-Output

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. 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. 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. 3

    Run it, then refine. Ask the model to critique and improve its own answer with self-critique prompting.

Techniques in this prompt

Role-Based

Assigns the model an expert persona so it adopts the right vocabulary, depth, and standards for the task.

Learn this technique
Few-Shot

Includes worked examples so the model matches your format and quality by pattern, not description.

Learn this technique
Structured Output

Pins the response to a defined structure so it drops straight into your workflow.

Learn this technique

Recommended models

claudegpt-4ogemini

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