mssql_manage_constraints
List, create, and drop SQL Server constraints and foreign keys using operations for get, create_fk, drop_fk, create, and drop.
Instructions
Manage SQL Server constraints - get, create foreign keys, drop foreign keys, create constraints, drop constraints. Examples: operation="get" to list constraints, operation="create_fk" with constraintName, tableName, columnNames, referencedTable, referencedColumns
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| schema | No | Schema name (defaults to dbo) | |
| cascade | No | Accepted for compatibility; SQL Server DROP CONSTRAINT has no CASCADE | |
| ifExists | No | Include IF EXISTS clause (for drop_fk/drop operations) | |
| onDelete | No | ON DELETE action (for create_fk); RESTRICT maps to NO ACTION | NO ACTION |
| onUpdate | No | ON UPDATE action (for create_fk); RESTRICT maps to NO ACTION | NO ACTION |
| clustered | No | CLUSTERED index for primary_key (default true) / unique (default false) | |
| operation | Yes | Operation: get (list constraints), create_fk (foreign key), drop_fk (drop foreign key), create (constraint), drop (constraint) | |
| tableName | No | Table name (optional filter for get, required for create_fk/drop_fk/create/drop) | |
| deferrable | No | Not supported by SQL Server; true is rejected | |
| columnNames | No | Column names in the table (required for create_fk and unique/primary_key create) | |
| constraintName | No | Constraint name (required for create_fk/drop_fk/create/drop) | |
| constraintType | No | Filter by constraint type (for get operation) | |
| checkExpression | No | Check expression (for create operation with check constraints) | |
| referencedTable | No | Referenced table name (required for create_fk) | |
| connectionString | No | SQL Server connection string (optional; requires --allow-tool-connection-string) | |
| referencedSchema | No | Referenced table schema (for create_fk, defaults to same as table schema) | |
| initiallyDeferred | No | Not supported by SQL Server; true is rejected | |
| referencedColumns | No | Referenced column names (required for create_fk) | |
| constraintTypeCreate | No | Type of constraint to create (for create operation) |