sql-objects

Generates SQL Server stored procedures, views, functions, and triggers following ERP conventions.

Updated Aug 18, 2026
One-click install
npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill sql-objects-aurelian1974
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: sql-objects
Source: https://github.com/Aurelian1974/ERPEnterprise/tree/main/.github/skills/sql-objects
Command: npx skills add https://github.com/Aurelian1974/ERPEnterprise --skill sql-objects-aurelian1974

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Writing ERP database objects by hand often leads to inconsistent naming, missing tenant isolation, SQL injection risks, and non-idempotent scripts. This Skill enforces strict conventions so every Stored Procedure, View, Table-Valued Function, Scalar Function, and Trigger follows the same multi-tenant, schema-prefixed standard. ## Core Features & Use Cases - Ready-to-use templates: Provides complete CREATE OR ALTER templates for INSERT, SELECT single row, paginated SELECT with filters, UPDATE, soft DELETE, CTE-based reports, Views, inline TVFs, Scalar Functions, and audit Triggers. - Strict convention enforcement: Mandates schema prefixes (finance., hr., inventory.), tenant_id filtering on every table and JOIN, explicit column aliases, SYSUTCDATETIME(), SET NOCOUNT ON, and bans SELECT * and unparameterized dynamic SQL. - Naming standards: Applies consistent prefixes such as usp_CreateInvoice, vw_InvoiceAging, tvf_InvoiceLines, fn_CalculateVAT, and trg_invoices_After_Update. - Use Case: Ask for a paginated invoice listing procedure and receive a complete finance.usp_ListInvoices with search, filters, sorting, OFFSET/FETCH pagination, and tenant isolation already built in. ## Quick Start Ask the assistant to write a stored procedure, view, function, or trigger for your ERP module, for example: create a stored procedure that lists invoices with pagination and tenant filtering.

Frequently Asked Questions about sql-objects

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

FAQPage Schema
How do I write a paginated stored procedure in SQL Server?▼

Use OFFSET and FETCH NEXT with ORDER BY for pagination, combined with nullable filter parameters like @Search, @Status, and @DateFrom. The template includes COUNT(*) OVER () for TotalCount and CASE-based dynamic sorting on whitelisted columns.

How to enforce multi-tenant isolation in SQL queries?▼

Add tenant_id = @TenantId to the WHERE clause of every table accessed and include AND t.tenant_id = @TenantId on every JOIN condition. Views expose tenant_id as a column so the calling procedure applies the filter.

Why use CREATE OR ALTER instead of CREATE in SQL Server?▼

CREATE OR ALTER makes scripts idempotent, so they can run repeatedly during deployments without failing on existing objects. It works for procedures, views, functions, and triggers, avoiding separate DROP or existence-check logic.

When should I use a trigger versus application-level auditing?▼

Prefer application-level auditing such as a MediatR behavior when the application controls the flow. Use triggers only when changes can bypass the application, capturing old and new values from the deleted and inserted pseudo-tables.

Why is SELECT * discouraged in stored procedures?▼

SELECT * breaks consumers when schemas change and returns unnecessary columns. Explicit column lists with AS aliases give C# consumers stable, clearly named result sets and reduce network and memory overhead.