Skip to content
IntoSQL home

Migration guides

SQL Server to SQL Server migration guide

Convert a SQL Server script from SSMS into a SQL Server script with the same tables, keys and data: how to script, convert, load, and every rule applied.

View as Markdown

IntoSQL reads the script SSMS writes with Generate Scripts and writes one SQL Server script with the same tables, columns, keys, indexes, foreign keys, defaults, counters, comments and rows. It reads the script itself, without a database server, and lists in the report every value SQL Server can't hold as it is and every object it doesn't carry. The script loads on SQL Server 2017 and later.

Convert in the browser: SQL Server to SQL Server opens the converter set up for this pair.

Script for the best result

In SQL Server Management Studio, right-click the database, choose Tasks, Generate Scripts, pick the tables, and under Advanced set Types of data to script to Schema and data. Save it as Unicode (SSMS's default) or UTF-8, as .sql or .sql.gz. dbatools (Export-DbaScript), mssql-scripter and other tools built on SQL Server Management Objects write the same script, from SQL Server 2017 on.

  • A script of the data alone still converts: the types are read from the values, and the report says the schema was missing (no_schema).
  • Tables on a partition scheme arrive as one table with every partition's rows (partitions_dropped), and a temporal table and its history table arrive as two plain tables.
  • SSMS doesn't script the values of computed and rowversion columns; computed columns are written again, and rowversion columns are reported (rowversion_empty).

Convert

In the browser, open SQL Server to SQL Server or the converter on the home page, drop the script and choose SQL Server. It reads the file from your disk in pieces, twice, and writes the new script as it goes, so the file is never uploaded and its size isn't limited by memory. The desktop app does the same with the file on disk.

With the command line:

Terminal
intosql inspect shop.sql
intosql convert shop.sql --to sql-server --output shop.sql_server.sql --report shop.report.json

inspect lists the tables, their rows and what won't be converted, without writing anything. convert writes the script and, with --report, the report as JSON.

Through the API, a script converts like any other file: open a conversion with its name ending in .sql or .sql.gz and "output": {"dialect": "sql_server"}.

Load into SQL Server

Terminal
sqlcmd -S localhost -Q "CREATE DATABASE shop"
sqlcmd -b -f 65001 -S localhost -d shop -i shop.sql_server.sql

-b stops at the first error and -f 65001 reads the script as UTF-8. Each schema stays a schema, every text column keeps its collation (a UTF-8 collation, which SQL Server 2017 lacks, becomes its Unicode twin), and xml, sql_variant, hierarchyid, geometry and geography stay as they are. datetimeoffset values keep their offsets. The script creates the tables, copies the rows with IDENTITY_INSERT, then adds indexes, foreign keys, identities and sequences. rowversion columns become empty binary(8), because the script has no values for them (rowversion_empty).

What isn't converted

Views, functions, procedures, triggers, synonyms, rules and security policies are written in T-SQL. They are listed in the report by kind and name, never dropped silently, so you can recreate them in SQL Server.

Data types

SQL Server data types between versions lists each type that changes in the script: what it becomes, why, and the report line.

Every other rule

Generated from the engine, where each rule is decided.

In the dump In the script Why Report line
column collations the same collation on each column Columns compare and sort as they did, and unique keys keep the same rows apart. None
CREATE SEQUENCE CREATE SEQUENCE with the same options SQL Server sequences work the same way. SSMS doesn't script where a sequence has reached, so it starts where it was created. None
computed columns the same computed columns, PERSISTED as in the source The same formulas, computed by the target. None
computed columns with functions IntoSQL doesn't write a plain column A formula that can't be written leaves a plain column and a report line; SSMS scripts no values for computed columns. generated_not_translated
defaults with functions IntoSQL doesn't write, and NEXT VALUE FOR no default A default that can't be written is left out and reported. default_not_translated
CHECK constraints translated The same checks, tested as each row loads. None
CHECK constraints with functions IntoSQL doesn't write not created A check that can't be written is left out and reported. check_skipped
CHECK constraints added WITH NOCHECK or disabled not created SQL Server doesn't apply these checks, so the rows may break them. check_not_enforced
filtered and columnstore indexes not created IntoSQL writes b-tree indexes on whole columns; create the others again after loading. index_skipped
foreign keys after the data WITH NOCHECK, then checked with a warning on orphans The key is created after the rows and checked last; rows without a parent leave it unchecked with a warning instead of stopping the load. None
ON DELETE or ON UPDATE that cascades in a cycle or along a second path NO ACTION SQL Server refuses those cascades, so a dump never holds one; the row is here for scripts edited by hand. foreign_key_action_dropped
foreign keys to tables the dump doesn't create not created A key can't name a table that isn't there. foreign_key_skipped
tables on a partition scheme one table with every partition's rows The rows are the same; partition the table again in SQL Server if it needs it. partitions_dropped
temporal tables (SYSTEM_VERSIONING) two tables: the current rows and the history The table and its history table are copied as plain tables; turn SYSTEM_VERSIONING on again to link them. system_versioning_dropped
NOT NULL columns with values that become NULL NOT NULL dropped A column whose values had to become NULL can't keep NOT NULL, or the load would stop. not_null_relaxed
views, functions, procedures, triggers, synonyms, types and partition functions listed in the report IntoSQL converts tables and their rows; the rest is listed for you to recreate from the original script. not_converted_objects
scripts without CREATE TABLE (data only) types read from the values A data-only script has only rows, so the types come from the values. no_schema
expressions in INSERT values NULL A converter that doesn't run a database can't evaluate them. expression_value
text decoded twice (ñ) copied as it is The script holds exactly these characters, so they are copied; the report points them out. mojibake_suspected