SynthForge SynthForge SynthForge IO

Integration · SQL Server · T-SQL · Azure SQL

Generate SQL Server test data, with foreign keys intact

Multi-table fixtures that load with BULK INSERT and import_sqlserver.sql. Free web sessions.

Short answer

Design a multi-table schema in SynthForge, generate, and download the SQL Server export. You get import_sqlserver.sql (CREATE TABLE with FKs plus BULK INSERT) and per-table CSVs. Every child row references a real parent by construction. Rewrite FROM 'csv/…' to absolute paths the server can read, then run with sqlcmd.

Why generate rather than hand-roll

.NET teams, SSIS packages, and enterprise staging still need multi-table seed data that respects foreign keys. Hand-written INSERT scripts and half-empty CSVs waste more time than the features they unblock.

SynthForge sorts tables by dependency, generates parents first, and samples FKs from IDs that exist. The same schema exports to Postgres, MySQL, or Cockroach when your org runs mixed engines.

How to do it

1. Define the schema

Describe tables in plain English, build them in the visual editor, or paste CREATE TABLE DDL. AI forge and SQL import both produce multi-table schemas with single-column foreign keys.

2. Set cardinality (optional)

Use relationship ratios such as "1 to 4 orders per customer" instead of inventing every child row count. Parents generate first; child foreign keys are sampled from real parent IDs.

3. Generate and export SQL Server

Pick SQL Server as the SQL dialect (or include SQL export in formats). The download ZIP contains import_sqlserver.sql (CREATE TABLE with FKs plus BULK INSERT loaders) and csv/<table>.csv data files. Identifiers use [brackets]; strings use NVARCHAR.

4. Rewrite CSV paths to absolute, then load

SQL Server BULK INSERT does not resolve relative paths the way psql or mysql do. The export uses FROM 'csv/<table>.csv' so the bundle stays portable; rewrite those paths to a location the SQL Server process can read, then run the script with sqlcmd (SQL Server 2017+ for FORMAT = 'CSV').

bash
# Extract the ZIP, then rewrite relative paths to absolute ones
# the SQL Server service account can read:
cd /path/to/extracted-bundle
sed -i "s|FROM 'csv/|FROM '$(pwd)/csv/|g" import_sqlserver.sql

# Create a database (once), then import
sqlcmd -S localhost -U sa -P 'YourStrong!Pass' -Q "CREATE DATABASE myapp_staging;"
sqlcmd -S localhost -U sa -P 'YourStrong!Pass' -d myapp_staging -b -i import_sqlserver.sql

# Loaders look like (after rewrite):
#   BULK INSERT [customers]
#   FROM '/path/to/extracted-bundle/csv/customers.csv'
#   WITH (FORMAT = 'CSV', FIRSTROW = 2, FIELDTERMINATOR = ',',
#         ROWTERMINATOR = '0x0a', TABLOCK);

5. Docker / Azure SQL notes

In Docker, copy the bundle into a path owned by the mssql user (for example /var/opt/mssql/load) - bind-mounting a 0700 host temp dir often fails with permission denied for uid 10001. Azure SQL Database does not support BULK INSERT from arbitrary client paths the same way; use bcp, Azure Blob + BULK INSERT FROM URL, or load via a jump box / container that can see the files.

bash
# Example: load into a local SQL Server container
docker cp . sf-mssql:/var/opt/mssql/load
docker exec -u 0 sf-mssql chown -R mssql:mssql /var/opt/mssql/load
# Rewrite FROM 'csv/…' → FROM '/var/opt/mssql/load/csv/…' inside the script
docker exec sf-mssql /opt/mssql-tools18/bin/sqlcmd \
  -S localhost -U sa -P 'YourStrong!Pass' -C \
  -d myapp_staging -b -i /var/opt/mssql/load/import_sqlserver.sql

6. (Optional) Agent path

With an API key and hosted MCP, agents can run description_to_dataset, download the ZIP, rewrite paths, and load with the same import_sqlserver.sql. First API key includes 10 free credits; web sessions stay free.

text
# MCP endpoint: https://mcp.synthforge.io/mcp
# Auth: Authorization: Bearer sfk_live_…
# Docs: https://synthforge.io/docs/mcp

Frequently asked questions

Why absolute paths for BULK INSERT?
SQL Server reads the file path on the server (or container) process, not relative to your shell cwd. Relative FROM 'csv/…' is portable in the ZIP, but you must rewrite to an absolute path the mssql service can open. This is documented in the import_sqlserver.sql header and verified in our multi-dialect load harness.
Does SQL Server enforce the foreign keys?
Yes. SynthForge emits ALTER TABLE … ADD CONSTRAINT FOREIGN KEY after the data loads, and the data is referentially valid by construction: child keys are drawn from generated parent IDs.
FORMAT = 'CSV' - which SQL Server versions?
BULK INSERT … WITH (FORMAT = 'CSV') requires SQL Server 2017 or later (and compatible Azure SQL / Linux containers). Older engines need a format file or alternative loaders.
How large a dataset can I generate?
Up to 10,000,000 rows per table per request, with per-account rate limits. Flat formats stream out of core; nested JSON stays full-RAM and is gated earlier.
Can I use the same schema for Postgres or MySQL?
Yes. One schema exports to PostgreSQL, MySQL, SQLite, SQL Server, MariaDB, DuckDB, and CockroachDB, plus CSV, JSON, JSONL, and Parquet.
Does SynthForge use my real production data?
No. It generates greenfield data from the schema you provide. It does not ingest or de-identify a live database. For anonymizing real data, use tools like Tonic or NVIDIA NeMo.

Related

Ready to seed SQL Server staging?

Generate multi-table SQL Server data with real foreign keys, rewrite paths once, load with sqlcmd. No credit card for the web app.