Extract SQL Server schema into a repository that supports team-scale change management.
SchemaTongs is the starting point of the SchemaSmith workflow. It connects to a SQL Server database and extracts metadata representing the current state of that database - tables, procedures, views, etc. This metadata becomes the raw material that feeds into the SchemaSmith toolchain for shaping and deploying your desired state across environments. We call this initial process of extracting schema definitions casting the database.
Simply point the application at each of your databases and everything within them will be extracted out to the folder of your choosing.
appSettings.json
Point SchemaTongs at your source database. All object types are extracted by default.
Use ObjectList to limit extraction to specific objects:
{
"Source": {
"Server": "localhost",
"Database": "AdventureWorks",
"User": "",
"Password": ""
},
"Product": {
"Path": "C:\\SchemaPackage",
"Name": "AdventureWorks"
},
"Template": {
"Name": "AdventureWorks"
},
"ShouldCast": {
"Tables": true,
"Schemas": true,
"UserDefinedTypes": true,
"UserDefinedFunctions": true,
"Views": true,
"StoredProcedures": true,
"TableTriggers": true,
"Catalogs": true,
"StopLists": true,
"DDLTriggers": true,
"XMLSchemaCollections": true,
"ScriptDynamicDependencyRemovalForFunctions": false,
"ObjectList": ""
}
}
Execute SchemaTongs from the command line and the casting process will begin.
> SchemaTongs
Move on to editing your metadata with SchemaHammer.
See the SchemaTongs Walkthrough to help you get started with the tool.
The same concepts for how to override appSettings.json for SchemaQuench apply to SchemaTongs. You can also use Command Line Options to specify the log file location or an alternate config file.
SchemaTongs extracts 11 object types from SQL Server. Tables are exported as JSON definitions; all other objects are exported as SQL scripts.
| Object Type | Directory | Format |
|---|---|---|
| Tables | Tables/ | JSON (schema.table.json) |
| Schemas | Schemas/ | SQL (schema.sql) |
| User-Defined Data Types | DataTypes/ | SQL |
| User-Defined Table Types | DataTypes/ | SQL |
| Functions | Functions/ | SQL (schema.name.sql) |
| Views | Views/ | SQL (schema.name.sql) |
| Stored Procedures | Procedures/ | SQL (schema.name.sql) |
| Table Triggers | Triggers/ | SQL (schema.table.trigger.sql) |
| DDL Triggers | DDLTriggers/ | SQL |
| Full-Text Catalogs | FullTextCatalogs/ | SQL |
| Full-Text Stop Lists | FullTextStopLists/ | SQL |
| XML Schema Collections | XMLSchemaCollections/ | SQL |
All directories are relative to
Product:Path/Templates/Template:Name/.
Encrypted objects (procedures, functions, views, and triggers
with WITH ENCRYPTION) cannot be scripted. SchemaTongs skips these objects
and logs a warning for each one encountered.
On the first cast to a new product path, SchemaTongs creates
Product.json and Template.json with default values,
along with JSON schema files in .json-schemas/ for editor
validation. All script folders are created physically on disk.
On subsequent casts, Product.json and Template.json
are never overwritten — only the extracted object scripts and table JSON files
are refreshed. New templates are added to the product's
TemplateOrder automatically.
After your first cast, review and customize
Product.json and Template.json, particularly
ValidationScript, DatabaseIdentificationScript, and
VersionStampScript, to match your deployment needs.
By default, SchemaTongs extracts all objects from the database. Set
ShouldCast:ObjectList to a comma or semicolon-separated list of
object names to limit extraction to specific objects only.
Matching is case-insensitive and supports both bare names and schema-qualified names:
"ObjectList": "MyTable" — matches dbo.MyTable, sales.MyTable, etc."ObjectList": "sales.MyTable" — matches only sales.MyTable"ObjectList": "MyTable,MyProc,sales.OrderView" — matches multiple objectsObjectList uses exact string matching only — no wildcards or regular expressions. The filter applies to all object types (tables, views, procedures, etc.).
The following objects are automatically excluded from extraction:
| Exclusion | Reason |
|---|---|
| Microsoft system objects | Objects with is_ms_shipped = 1 in sys.objects. |
SchemaSmith schema |
Helper infrastructure installed by SchemaTongs itself (functions, procedures, tables). |
| System schemas | Schemas with schema_id <= 4 (dbo, guest, INFORMATION_SCHEMA, sys) and db_* patterns. |
| Replication tables | Tables matching MSPeer_% or MSPub_% patterns. |
| Diagram metadata | dtproperties and sysdiagrams tables (SSMS diagram storage). |
Before extraction, SchemaTongs installs helper objects in a
[SchemaSmith] schema on the source database. These objects are
used during extraction and deployment. They include:
fn_StripParenWrapping,
fn_StripBracketWrapping, fn_SafeBracketWrap,
fn_FormatJson — string manipulation and JSON formatting helpers.GenerateTableJSON — extracts
complete table definitions as JSON. PrintWithNoWait — real-time
console output during operations. Plus table quench procedures used by
SchemaQuench at deployment time.CompletedMigrationScripts — tracks
which migration scripts have been executed to prevent re-execution.
These objects are excluded from extraction output automatically.
The SkipKindlingForge command-line argument can skip this
installation step if the helpers are already present.
When SchemaTongs re-extracts into an existing schema package, it preserves user-configured properties that were added after the initial extraction. This means you can safely re-run SchemaTongs without losing your customizations.
Preserved on table JSON files:
ContentFile, MergeType,
MatchColumns, MergeFilter,
MergeDisableTriggersOldName (for tracking table renames)
Components are matched by name (case-insensitive) or by OldName
for renamed objects. Schema structure is always refreshed from the database;
only user-defined metadata is preserved.
Programmable objects (functions, views, procedures, triggers) are extracted
with their original SET ANSI_NULLS and
SET QUOTED_IDENTIFIER settings, followed by a
CREATE OR ALTER statement. The script body preserves the
exact formatting from the database.
All line endings are normalized to \r\n (Windows CRLF)
regardless of the source database platform.
| Flag | Default | Description |
|---|---|---|
Tables |
true |
Extract table definitions as JSON files. Includes columns, indexes, foreign keys, check constraints, and extended properties. |
Schemas |
true |
Extract user-defined schemas (excludes system schemas like dbo, sys, guest). |
UserDefinedTypes |
true |
Extract user-defined alias types and table types. |
UserDefinedFunctions |
true |
Extract scalar functions (FN), inline table-valued functions (IF), and multi-statement table-valued functions (TF). |
Views |
true |
Extract view definitions. |
StoredProcedures |
true |
Extract stored procedure definitions. |
TableTriggers |
true |
Extract DML triggers on tables (parent_class = 1). |
Catalogs |
true |
Extract full-text catalogs. |
StopLists |
true |
Extract full-text stop lists. |
DDLTriggers |
true |
Extract database-level DDL triggers (parent_class = 0). |
XMLSchemaCollections |
true |
Extract XML schema collections. |
ScriptDynamicDependencyRemovalForFunctions |
false |
When enabled, each function script includes a preamble that dynamically drops computed column constraints, indexes, and dependencies before the CREATE OR ALTER. SchemaQuench restores them when processing managed tables. Use when functions are referenced by computed columns or filtered indexes. |
ObjectList |
"" |
Comma or semicolon-separated list of object names to extract. Leave empty to extract all objects. See Extraction Details. |