← 返回
数据分析 Key 中文

Sql Server Skills

Expertise in diagnosing SQL Server performance issues, analyzing indexes, interpreting execution plans, optimizing queries, managing schema, backups, and mon...
精通SQL Server性能问题诊断、索引分析、执行计划解读、查询优化、架构管理、备份与监控。
vince-winkintel
数据分析 clawhub v1.0.0 1 版本 100000 Key: 需要
★ 0
Stars
📥 581
下载
💾 71
安装
1
版本
#latest

概述

SQL Server Skills

Comprehensive SQL Server skill for AI agents. Covers performance diagnostics, index analysis, execution plan interpretation, query optimization, schema management, backup/restore, and monitoring — all via sqlcmd and T-SQL DMVs.


Requirements

  • sqlcmdMicrosoft Download
  • SQL Server 2016+ — All DMV queries target compatibility level 130+
  • PermissionsVIEW SERVER STATE for most DMV queries; sysadmin or db_owner for some operations

Quick Connect

# Windows Authentication (domain-joined machine)
sqlcmd -S "$SQL_SERVER" -E

# SQL Authentication
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE"

# Named instance + specific database
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE"

# Run a diagnostic script
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/top-slow-queries.sql

# Run with output to file
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/wait-stats.sql -o results.txt -s "," -W

Skill Organization

Sub-SkillPathUse When
---------------------------
Diagnosticssqlserver-diagnostics/SKILL.mdServer is slow — find the bottleneck (wait stats, slow queries, active requests)
Indexessqlserver-indexes/SKILL.mdFind missing indexes, fix fragmentation, drop unused indexes
Execution Planssqlserver-execution-plans/SKILL.mdRead and interpret query execution plans, spot bad operators
Query Optimizationsqlserver-query-optimization/SKILL.mdFix stored procedures, views, anti-patterns, parameter sniffing
Schemasqlserver-schema/SKILL.mdCREATE/ALTER TABLE, migrations, constraints, data types
Backup/Restoresqlserver-backup/SKILL.mdBACKUP DATABASE, RESTORE, check backup history
Monitoringsqlserver-monitoring/SKILL.mdSQL Agent jobs, error log, blocking, deadlocks, long-running transactions

Decision Tree — What Are You Trying To Do?

Is the server slow or a query timing out?
├── I don't know WHERE the bottleneck is → sqlserver-diagnostics
│   └── Start with wait-stats.sql, then top-slow-queries.sql
│
├── I have a specific slow query → sqlserver-execution-plans
│   └── Capture the plan, identify bad operators
│
├── I suspect missing or broken indexes → sqlserver-indexes
│   └── Run missing-indexes.sql + index-fragmentation.sql
│
└── I want to rewrite/fix bad T-SQL code → sqlserver-query-optimization
    └── Check anti-patterns: cursors, non-SARGable, DELETE+INSERT loops

Is there a blocking/locking issue?
└── sqlserver-monitoring (blocking-analysis.sql)

Do I need to change the schema?
└── sqlserver-schema

Do I need to backup or restore a database?
└── sqlserver-backup

Do I need to check SQL Agent jobs or the error log?
└── sqlserver-monitoring

Common Workflows

Workflow 1: Server Is Slow — Start Here

# Step 1: What is SQL Server waiting on?
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/wait-stats.sql

# Step 2: Which queries are consuming the most resources?
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/top-slow-queries.sql

# Step 3: What's running right now?
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/active-queries.sql

Then read sqlserver-diagnostics/SKILL.md to interpret results.


Workflow 2: Optimize a Specific Query

-- Step 1: Capture I/O and time stats
SET STATISTICS IO ON;
SET STATISTICS TIME ON;
GO
-- paste your query here
GO

-- Step 2: Get XML execution plan
SET STATISTICS XML ON;
GO
-- paste your query here
GO
SET STATISTICS XML OFF;

Then read sqlserver-execution-plans/SKILL.md to interpret the plan.


Workflow 3: Monthly Index Maintenance

# Find missing indexes (sorted by impact score)
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE" -i scripts/missing-indexes.sql

# Check fragmentation
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE" -i scripts/index-fragmentation.sql

# Find unused indexes costing write overhead
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d "$SQL_DATABASE" -i scripts/unused-indexes.sql

See sqlserver-indexes/SKILL.md for interpretation and the rebuild/reorganize decision.


Workflow 4: Investigate Blocking

# Run blocking analysis
sqlcmd -S "$SQL_SERVER" -U "$SQL_USER" -P "$SQL_PASSWORD" -d master -i scripts/blocking-analysis.sql

See sqlserver-monitoring/SKILL.md for deadlock investigation and KILL guidance.


Sub-Skill Quick Reference

  • sqlserver-diagnostics/SKILL.md — DMV-based bottleneck analysis (most important starting point)
  • sqlserver-indexes/SKILL.md — Full index lifecycle: find, fix, maintain, drop
  • sqlserver-execution-plans/SKILL.md — Read plans, spot table scans, fix key lookups
  • sqlserver-query-optimization/SKILL.md — Stored proc rewrites, anti-patterns, hints
  • sqlserver-schema/SKILL.md — DDL patterns, migrations, data type guidance
  • sqlserver-backup/SKILL.md — Backup/restore commands and history queries
  • sqlserver-monitoring/SKILL.md — Jobs, error log, blocking, deadlocks

版本历史

共 1 个版本

  • v1.0.0 当前
    2026-03-30 22:28 安全 安全

安全检测

腾讯云安全 (Keen)

安全,无风险
查看报告

腾讯云安全 (Sanbu)

安全,无风险
查看报告

🔗 相关推荐

data-analysis

Excel / XLSX

ivangdavila
创建、检查和编辑 Microsoft Excel 工作簿及 XLSX 文件,支持可靠的公式、日期、类型、格式、重算及模板保留功能。
★ 368 📥 140,466
data-analysis

A股量化 AkShare

mbpz
A股量化数据分析工具,基于AkShare库获取A股行情、财务数据、板块信息等。用于回答关于A股股票查询、行情数据、财务分析、选股等问题。
★ 165 📥 60,018
developer-tools

Gitlab Cli Skills

vince-winkintel
全面的 GitLab CLI (glab) 命令参考和工作流,涵盖所有 GitLab 操作。适用于处理合并请求、CI/CD 流水线、问题、发布等场景。
★ 8 📥 6,179