write-script-mssql

Write parameterized MSSQL queries with named parameters and descriptive comments.

Updated Feb 21, 2026
One-click install
npx skills add https://github.com/adamkingsbury/unified-data-model --skill write-script-mssql-adamkingsbury
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: write-script-mssql
Source: https://github.com/adamkingsbury/unified-data-model/tree/main/.claude/skills/write-script-mssql
Command: npx skills add https://github.com/adamkingsbury/unified-data-model --skill write-script-mssql-adamkingsbury

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Writing MS SQL Server queries without consistent practices leads to injection risks and maintainability issues. This Skill provides a clear guide to write parameterized, well-documented MSSQL statements.

Core Features & Use Cases

  • Parameter naming convention: Use @P1, @P2, etc., and name parameters with a preceding comment to map to their roles.
  • Safety and maintainability: Encourages parameterization, comments, and simple patterns that reduce errors in complex queries.
  • Use Case: A developer writing a stored procedure or a dynamic SQL script in SQL Server.

Quick Start

Follow this guideline whenever you craft MSSQL queries to ensure parameterized, well-documented statements.

Frequently Asked Questions about write-script-mssql

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I write parameterized MSSQL queries to prevent SQL injection?

To write parameterized MSSQL queries, use named parameters like @P1 and @P2, and add descriptive comments before statements to map parameters to values. This standardization reduces injection risks and improves maintainability for stored procedures and ad-hoc scripts.

What is the best way to standardize T-SQL scripts for data migrations?

Standardizing T-SQL scripts for data migrations involves enforcing parameterized queries with consistent naming conventions like @P1, and requiring descriptive comments before statements. This ensures safer queries and reduces errors during complex SQL Server migrations.

Why does my SQL Server stored procedure lack maintainability and safety?

Your SQL Server stored procedure lacks safety and maintainability if it does not use parameterized queries. Enforcing named parameters like @P1 and adding comments to map parameter values reduces injection risks and ensures consistent, documented T-SQL patterns.

Can I use named parameters like @P1 for ad-hoc queries in SQL Server?

Yes, you can use named parameters like @P1 for ad-hoc queries in SQL Server. Standardizing your MSSQL query writing with parameterized statements and preceding comments to map parameters to values significantly reduces errors and injection risks.

Does this approach to writing MSSQL statements work for dynamic SQL?

Yes, this approach works for dynamic SQL. Writing parameterized MSSQL statements with named parameters like @P1 and adding descriptive comments to map parameter values reduces injection risks and maintainability issues in dynamic SQL Server environments.

What are the limitations of using @P1 named parameters in T-SQL queries?

Using named parameters like @P1 in T-SQL queries requires adding descriptive comments before statements to map parameters to their roles. Without these comments, the parameterized queries lose maintainability and become difficult to interpret in complex scripts.