Convert a MySQL schema to SQL Server
Paste the CREATE TABLE statements from MySQL and ERD Designer draws them as a diagram. Change the diagram's target database to SQL Server and every column's datatype is converted. You review each change before it is applied, then generate the SQL Server script.
What changes in the sample
Converted to SQL Server 2022, these columns of the sample above change type. Everything else keeps its type; names, keys, nullability and lists of allowed values are left as they are.
| Column | MySQL | SQL Server | Note |
|---|---|---|---|
customers.email | VARCHAR(255) | NVARCHAR(255) | |
customers.full_name | VARCHAR(120) | NVARCHAR(120) | |
customers.notes | LONGTEXT | NVARCHAR(MAX) | |
customers.is_active | TINYINT(1) | BIT | |
customers.created_at | DATETIME(3) | DATETIME2(3) | default: CURRENT_TIMESTAMP(3) → CURRENT_TIMESTAMP |
orders.status | ENUM | NVARCHAR(7) | |
orders.placed_at | TIMESTAMP | DATETIME2 | |
orders.receipt_pdf | MEDIUMBLOB | VARBINARY(MAX) |
What you are asked
Where SQL Server offers more than one fair answer, ERD Designer asks before it converts — once per kind of column, not once per column. For this page each question was answered with its first option:
orders.status — answered NVARCHAR(7)
NVARCHAR(7)— this column, held to the list by a CHECK constraintLookup table— a new table holding the values, keyed by the value itself, with a foreign key from this column
The sample converts with nothing to warn about. A schema that loses something on the way — a time zone, a precision, a type SQL Server does not have — gets a message naming the column and what changed.
The SQL Server script
This is what ERD Designer generates for the sample, for SQL Server 2022. Our test suite applies this conversion to a real SQL Server server and then reads the database back to confirm it matches the diagram exactly.
-- Create table customers
CREATE TABLE [customers] (
[customer_id] INT IDENTITY(1,1) NOT NULL,
[email] NVARCHAR(255) NOT NULL,
[full_name] NVARCHAR(120) NOT NULL,
[notes] NVARCHAR(MAX) NULL,
[is_active] BIT NOT NULL CONSTRAINT [DF_customers_is_active] DEFAULT (1),
[created_at] DATETIME2(3) NOT NULL CONSTRAINT [DF_customers_created_at] DEFAULT (CURRENT_TIMESTAMP),
CONSTRAINT [customers_PK] PRIMARY KEY ([customer_id])
);
-- Create table orders
CREATE TABLE [orders] (
[order_id] BIGINT IDENTITY(1,1) NOT NULL,
[customer_id] INT NOT NULL,
[status] NVARCHAR(7) NOT NULL CONSTRAINT [DF_orders_status] DEFAULT (N'new') CHECK ([status] IN (N'new', N'paid', N'shipped')),
[total] DECIMAL(12,2) NOT NULL,
[placed_at] DATETIME2(7) NOT NULL,
[receipt_pdf] VARBINARY(MAX) NULL,
CONSTRAINT [orders_PK] PRIMARY KEY ([order_id])
);
-- Add unique constraint on customers (email)
ALTER TABLE [customers] ADD CONSTRAINT [customers_email_uq] UNIQUE ([email]);
-- Create index on orders (placed_at)
CREATE INDEX [orders_placed_ix] ON [orders] ([placed_at]);
-- Add foreign key orders (customer_id) → customers (customer_id)
ALTER TABLE [orders] ADD CONSTRAINT [orders_FK1] FOREIGN KEY ([customer_id]) REFERENCES [customers] ([customer_id]);
How to convert your own schema
- Paste your MySQL script above and press Open in ERD Designer. The diagram opens laid out and ready to edit.
- Click the diagram's name in the toolbar to open its properties, choose SQL Server under Target Database / Version, and press Apply Changes.
- If SQL Server offers more than one way to store a kind of column, choose one and press Continue.
- Read the list of retyped columns and any warnings, then press Apply Conversion. Save the diagram to keep it.
- Press Generate DDL (the database icon) to copy or download the SQL Server script — or apply it to a database on your own network with the ERD Designer Agent.
What it reads, and what it does not
- It reads
CREATE TABLE,ALTER TABLE … ADD CONSTRAINTandCREATE INDEX: tables, columns, keys, foreign keys, unique constraints, check lists and indexes. Anything else in the script is skipped and listed. - It converts the schema, never the data: no rows are read, moved or changed.
- It does not convert views, stored procedures, functions, triggers or packages.
Which plan you need
Pasting a script and working with it as a diagram is free on the Basic plan, with no card. Converting a diagram to another database is part of the Pro and Advanced plans, which also generate its script and can apply it through the Agent.
Other conversions
- MySQL to PostgreSQL
- MySQL to Oracle
- MySQL to MariaDB
- MySQL to SQLite
- MySQL to Amazon Redshift
- MySQL to Google BigQuery
- MySQL to Snowflake
- PostgreSQL to SQL Server
- Oracle to SQL Server
- MariaDB to SQL Server
- SQLite to SQL Server
- Amazon Redshift to SQL Server
- Google BigQuery to SQL Server
- Snowflake to SQL Server
Questions? Write to support@erddesigner.com. · ERD Designer · Terms · Privacy