build_create_table
Builds a CREATE TABLE script from a table name and column definitions, validates primary/foreign keys and indexes against the cached schema, returns SQL + undo SQL + notes; no DDL executed.
Instructions
Generate a CREATE TABLE script (TEXT ONLY -- this server never runs DDL; the user reviews and runs it). Checked against the cached schema: the name must be free, foreign keys must point at a real primary/unique key with the same column types, FK columns get an index, constraints get conventional names, and the script is wrapped in IF OBJECT_ID(...) IS NULL so it can be re-run. Returns sql + undo_sql + notes.
name: "dbo.VendorScore" columns: [{"name": "VendorScoreId", "type": "int", "identity": true}, {"name": "VendorId", "type": "int", "nullable": false}, {"name": "Score", "type": "decimal(5,2)", "nullable": false, "default": "0", "description": "0-100"}] primary_key: ["VendorScoreId"] foreign_keys: [{"columns": ["VendorId"], "references": "dbo.Vendor"}] (ref_columns default to the parent's primary key) indexes: [{"columns": ["ScoredOn"], "include": ["Score"], "unique": false}]
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| name | Yes | ||
| columns | Yes | ||
| indexes | No | ||
| connection | No | ||
| description | No | ||
| primary_key | No | ||
| foreign_keys | No |