How artemedi/ms-sql works
Purpose and usage model
This is a curated operational runbook of mostly ad hoc Microsoft SQL Server scripts, organized by DBA task rather than a deployable application. There is no declared executable entry point, build system, or README guidance. Operators select and run scripts manually in SQL Server tooling against the appropriate instance/database; a small Windows-tuning set uses PowerShell and Registry artifacts.
Operational monitoring and alerts
Alerting scripts query database/server state and can surface conditions through SQL Server Agent-related mechanisms or Slack integrations. Mirrored-database alerts are a distinct scenario.
• Alerts/Alerts.sql
• Alerts/Slack SP.sql
• Alerts/Slack Trigger.sql
Server/database audit and inventory
The Audit area gathers instance metadata, users/roles/SIDs, permissions, object definitions, table/index sizes, and cross-database discovery results. These scripts form a read-oriented assessment boundary, though some audit utilities may persist or create database objects.
• Audit/Get SQL and Windows info.sql
• Audit/Get users and roles.sql
• Audit/Size all DBS.sql
Diagnostics and performance investigation
Troubleshooting scripts provide the largest diagnostic workflow: inspect active sessions, CPU, I/O, memory, cache, locks/latches, waits, TempDB, execution plans, and transaction-log reuse/growth. Inputs are SQL Server DMVs, system views, plans, and logs; outputs are query result sets for operator interpretation.
• Troubleshooting/Active sessions.sql
• Troubleshooting/CPU/High CPU investigation.sql
• Troubleshooting/Waits/Server waits.sql
Event capture and historical telemetry
Extended Events scripts define or inspect server/database event sessions for failures, deadlocks, expensive queries, logins, resource consumption, spills, and page splits. This is the principal capture boundary: event sessions collect runtime activity, then companion scripts read settings or captured data.
• Extendet Events/Deadlocks.sql
• Extendet Events/Expensive Queries.sql
• Extendet Events/CheckFailedLogins.sql
Maintenance, recovery, and data movement
Scripts support backup verification, restore and point-in-time recovery, index/statistics maintenance, BCP/BULK INSERT transfer, and partition/filegroup analysis. These are mutating or infrastructure-impacting operations and must be run with database-specific paths, credentials, and recovery constraints.
• Backup&Restore/Backup+verify.sql
• Backup&Restore/RestoreDB.sql
• Indexes/Index maitenance.sql
• BCP/BULK INSERT.sql
Availability, integration, and scheduled operations
Topology-specific scripts cover Always On readable replicas, mirroring, replication, linked servers, SQL Agent jobs, Database Mail, SSIS, and Azure SQL diagnostics. They cross server/database boundaries and depend on configured SQL Server infrastructure and, for Slack, an external notification endpoint.
• AlwaysOn/Read from ReadOnly Node For AlwaysOn.sql
• Replications/Transactional Replication Status Checker.sql
• Jobs/CheckJobExecution.sql
Governance and host-level administration
Policy-Based Management scripts define conditions, policies, remediation stored procedures, and retention behavior. Windows scripts separately alter host services, memory compression, registry tuning, and presentation settings; these require Windows administrative execution rather than SQL execution.
• Policy/Policies/CheckDatabaseSettings.sql
• Policy/StoredProcedures/FixDbSettings.sql
• WindowsTunning/EnableMemoryCompression.ps1
Main entry points: Get SQL and Windows info.sql Audit and inventory · Active sessions.sql Performance diagnostics · Alerts.sql Alert scripts · RestoreDB.sql Maintenance and recovery
Components 19
Manual execution
Operators choose scripts and run them in SQL Server tooling or Windows shells.
- DBA operator · Selects the appropriate runbook and interprets results.
- SQL Server tooling · Manual T-SQL execution against a selected instance or database.
- Windows admin shell · Runs host-level tuning artifacts with administrative privileges.
- Operator result sets · Assessment and diagnostic findings requiring operator interpretation.
SQL operational runbooks
Task-oriented T-SQL scripts for assessment, investigation, and change.
- Audit and inventory · Reads instance metadata, identities, permissions, objects, and sizing data.
Audit/Get SQL and Windows info.sql - Performance diagnostics · Investigates sessions, CPU, I/O, memory, locks, waits, TempDB, plans, and logs.
Troubleshooting/Active sessions.sql - Maintenance and recovery · Performs backup verification, restore, index/statistics work, and recovery actions.
Backup&Restore/RestoreDB.sql - BCP and BULK transfer · Moves data through BCP or BULK INSERT using environment-specific inputs.
BCP/BULK INSERT.sql - Availability and jobs · Works with replicas, replication, linked servers, Agent jobs, Mail, SSIS, and Azure diagnostics.
AlwaysOn/Read from ReadOnly Node For AlwaysOn.sql - Policy governance · Defines policy checks and database-settings remediation procedures.
Policy/Policies/CheckDatabaseSettings.sql
Capture and notifications
Runtime event capture and operational alert delivery.
- Alert scripts · Queries conditions and can invoke Agent or Slack-oriented alert mechanisms.
Alerts/Alerts.sql - Slack integration · Stored procedure and trigger artifacts for Slack notifications.
Alerts/Slack SP.sql - Extended Events scripts · Defines or inspects sessions for failures, deadlocks, costly queries, logins, and resource events.
Extendet Events/Deadlocks.sql - Event sessions and captures · Persisted session definitions and captured runtime activity.
SQL and host infrastructure
Target instances, configured services, and Windows hosts.
- DMVs, plans, and logs · Primary diagnostic inputs exposed by SQL Server.
- SQL Server infrastructure · Instances, databases, Agent, replication, replicas, and related configured services.
- Windows tuning · Changes host services, memory compression, registry, or presentation settings.
WindowsTunning/EnableMemoryCompression.ps1 - Windows host · Server operating system requiring administrative access for tuning.
- Slack endpoint · Configured external destination for operational notifications.
Connections 25
- DBA operator → SQL Server tooling: runs manually
- DBA operator → Windows admin shell: runs manually
- SQL Server tooling → Alert scripts: executes
- SQL Server tooling → Audit and inventory: executes
- SQL Server tooling → Performance diagnostics: executes
- SQL Server tooling → Extended Events scripts: executes
- SQL Server tooling → Maintenance and recovery: executes
- SQL Server tooling → BCP and BULK transfer: executes
- SQL Server tooling → Availability and jobs: executes
- SQL Server tooling → Policy governance: executes
- Alert scripts → SQL Server infrastructure: checks
- Alert scripts → Slack integration: uses
- Slack integration → Slack endpoint: notifies
- Audit and inventory → SQL Server infrastructure: assesses
- Audit and inventory → Operator result sets: returns
- Performance diagnostics → DMVs, plans, and logs: queries
- Performance diagnostics → Operator result sets: returns
- Extended Events scripts → Event sessions and captures: defines and reads
- Event sessions and captures → DMVs, plans, and logs: captures activity from
- Maintenance and recovery → SQL Server infrastructure: changes or recovers
- BCP and BULK transfer → SQL Server infrastructure: imports or exports
- Availability and jobs → SQL Server infrastructure: operates across
- Policy governance → SQL Server infrastructure: checks and remediates
- Windows admin shell → Windows tuning: executes
- Windows tuning → Windows host: modifies