/microsoft-sql-admin:ledger-tablesfrom Microsoft SQL administration
Creates, queries, and manages SQL Server 2022+ ledger tables for tamper-evident audit trails. Covers updatable and append-only ledger tables, history queries via system-created ledger views, and listing ledger tables.
Ships in Microsoft SQL administration. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Use this skill when the user asks about ledger tables, creating ledger tables, querying historical ledger data, or auditing data changes.
microsoft-sql-admin plugin (mssql_list_database_connections,
mssql_connect_database, then mssql_execute_query); any other SQL tool the agent host provides
for running T-SQL and reading result sets;
sqlcmd from a terminal. The same
tool also creates ledger tables when the user asks you to make the change. If the SQL Tools MCP
server is not connected or lists no connections, follow the sql-tools-mcp-setup skill, which
asks before installing or configuring anything. If no SQL tool can be made available, give the
user the T-SQL to run and ask for the results.SELECT name FROM sys.tables
WHERE ledger_type = 1
AND object_id = (SELECT history_table_id FROM sys.tables WHERE name = '$LedgerTableName' AND ledger_type = 2)
OPTION (MAXDOP 1);
SELECT name AS LedgerViewName
FROM sys.views
WHERE object_id = '$LedgerViewID'
OPTION (MAXDOP 1);
SELECT
SCHEMA_NAME(schema_id) AS SchemaName,
name AS TableName,
ledger_type_desc AS LedgerType,
ledger_view_id
FROM sys.tables
WHERE ledger_type IN (2, 3)
AND is_dropped_ledger_table = 0
ORDER BY SchemaName, TableName
OPTION (MAXDOP 1);
SYSTEM_VERSIONING = ON (temporal tables) to maintain full history of changes.sys.tables.sys.tables.XML, SqlVariant, User-defined, FILESTREAM, Vector
When asked about historical data for a table:
object_id from sys.tables.ledger_view_idDO NOT use the history table directly unless specifically asked.
DO NOT use undocumented functions like DBCC log, fn_dblog(), fn_dump_dblog(), fn_full_dblog().
| Column | Type | Description |
|---|---|---|
| ledger_transaction_id | BIGINT | Transaction ID that created/deleted a row |
| ledger_sequence_number | BIGINT | Sequence number of row operation |
| ledger_operation_type | TINYINT | 1 = INSERT, 2 = DELETE |
| ledger_operation_type_desc | NVARCHAR(128) | INSERT or DELETE |
| Column | Values |
|---|---|
| ledger_type | 0=Non-ledger, 1=History, 2=Updatable, 3=Append-only |
| ledger_view_id | object_id of the ledger view (for types 2 and 3) |
| is_dropped_ledger_table | bit — dropped but preserved for auditing |
DO NOT include dropped ledger tables or history tables when listing ledger tables unless specifically asked.
CREATE TABLE [schema].[table_name]
(
column1 datatype,
ledger_start_transaction_id BIGINT GENERATED ALWAYS AS TRANSACTION_ID START,
ledger_end_transaction_id BIGINT GENERATED ALWAYS AS TRANSACTION_ID END,
ledger_start_sequence_number BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START,
ledger_end_sequence_number BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER END
)
WITH
(
SYSTEM_VERSIONING = ON (HISTORY_TABLE = [schema].[history_table_name]),
LEDGER = ON (
LEDGER_VIEW = [schema].[view_name] (
TRANSACTION_ID_COLUMN_NAME = ledger_transaction_id,
SEQUENCE_NUMBER_COLUMN_NAME = ledger_sequence_number,
OPERATION_TYPE_COLUMN_NAME = ledger_operation_type,
OPERATION_TYPE_DESC_COLUMN_NAME = ledger_operation_type_desc
)
)
);
CREATE TABLE [schema].[table_name]
(
column1 datatype,
ledger_start_transaction_id BIGINT GENERATED ALWAYS AS TRANSACTION_ID START,
ledger_start_sequence_number BIGINT GENERATED ALWAYS AS SEQUENCE_NUMBER START
)
WITH
(
LEDGER = ON (
APPEND_ONLY = ON,
LEDGER_VIEW = [schema].[view_name] (
TRANSACTION_ID_COLUMN_NAME = ledger_transaction_id,
SEQUENCE_NUMBER_COLUMN_NAME = ledger_sequence_number,
OPERATION_TYPE_COLUMN_NAME = ledger_operation_type,
OPERATION_TYPE_DESC_COLUMN_NAME = ledger_operation_type_desc
)
)
);
If the user does not specify updatable vs. append-only, ask for clarification before creating.
What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
npx claudepluginhub microsoft/microsoft-sql --plugin microsoft-sql-admin47 skills in this plugin
/active-connectionsUse when the user asks who is connected, which sessions are idle or hold the oldest open transaction, or how connections split by login or app. If a client can't connect, use `connectivity-troubleshoot`./always-encrypted-columnsUse when the user asks which plaintext columns can or should use Always Encrypted, or why a column is disqualified. Eligibility only: not for listing already-encrypted columns or their keys./authentication-diagnosticsUse when a login fails (18456, 'Login failed for user'), a user can't open a database, a permission is denied, or an Entra or managed identity login fails. For network errors, use `connectivity-troubleshoot`.Other plugins' skills for the same job