Wednesday, March 11, 2026

DBA discussion

 Here is a detailed prompt for creating a database administrator (DBA) automation tool. This prompt can be used with GitHub Copilot, ChatGPT, or Gemini.

The "Master" Prompt:

"As a SQL Server DBA, I aim to automate backup reporting for Always On Availability Groups (AG). Please create a Python or PowerShell script that performs the following tasks:
  1. Server Connection: Connect to the SQL environment using Windows Authentication. Automatically identify primary and secondary replicas using the AG Listener.
  2. Data Extraction: Query the msdb..backupset and msdb..backupmediafamily tables across all nodes to find the last successful backup (Full, Differential, and Log) for every database.
  3. Intelligence Logic: Flag any database without a Full Backup in more than 7 days as 'MISSING' or 'CRITICAL'.
  4. Dashboard Generation: Generate a color-coded HTML report (Dashboard) with columns for Database Name, Last Backup Date/Time, Backup Type, File Location, and Status (SUCCESS/FAILED/MISSING).
  5. Email Automation: Include a function to send the formatted HTML report as an email summary to the DBA team.
Ensure the code includes error handling, secure connection strings, and comments explaining each step."

Pro Tips for a Better Result:

  • Specify the SQL Server version (e.g., "for SQL Server 2022") to ensure accurate T-SQL syntax.
  • Include server naming conventions or preferred libraries (like pyodbc for Python or SqlServer module for PowerShell) in the prompt.
  • Iterate: After the AI generates the first draft, request additional features like handling offline servers or formatting the HTML table with CSS.

No comments:

Post a Comment

Thanks For Visit

DBA discussion

 Here is a detailed prompt for creating a database administrator (DBA) automation tool. This prompt can be used with GitHub Copilot, ChatGPT...