sqlserver
mongodb

Migrate SQL Server to MongoDB

Beta — live-tested path

MongoDB has no fixed schema, so there is no column-type table for this direction: each SQL Server row becomes one document, and the section below shows how each kind of value lands. DBShifts copies the rows in parallel batches and checks the result with row counts.

Start SQL Server → MongoDB Migration

Free tier · no credit card

SQL Server vs MongoDB

sqlserver

SQL Server

Microsoft's enterprise relational database.

mongodb

MongoDB

the leading document database.

How values land in MongoDB

MongoDB has no fixed schema, so there's no column-type table to show — this is what actually happens to each value on the way in.

  • DECIMAL and MONEY values are stored as exact Decimal128, never a lossy float.
  • DATE columns with no time component land as a BSON date at midnight UTC — BSON has no date-only type.
  • TIME-only values are stored as an ISO-8601 string — BSON has no time-only type.
  • DATETIME / DATETIME2 columns become native BSON dates.
  • Each row becomes one document — there's no fixed collection schema to map into, so this is about value fidelity, not a type-mapping table.

Example: SQL Server to MongoDB conversion

SQL Server

CREATE TABLE users (
  id INT IDENTITY(1,1) PRIMARY KEY,
  name NVARCHAR(255) NOT NULL,
  is_active BIT DEFAULT 1,
  created_at DATETIME2 DEFAULT SYSUTCDATETIME()
);

MongoDB

{
  id: 1,
  name: "Ada Lovelace",
  is_active: true,
  created_at: ISODate("2026-01-15T10:30:00Z")
}

One collection per table is the wrong default

The mechanical conversion — each table becomes a collection, each row a document — produces a MongoDB database that is a relational database with the joins removed. Every query that used to be a join becomes several round trips plus application-side assembly, and the result performs worse than the SQL Server it replaced while being harder to reason about.

The decision that actually matters is which relationships to embed and which to reference. An order and its line items are read together, written together and bounded in size: embed them, and one document read replaces a join. A customer and their orders are unbounded and read separately: reference them. Getting this right is the entire migration; the data movement is trivial by comparison.

Decimal survives, but only if you ask for it

MongoDB has a genuine exact decimal type, Decimal128, which maps cleanly from SQL Server's DECIMAL and NUMERIC. It is not the default. A naive conversion sends DECIMAL(10,2) to a double, which is binary floating point, and monetary values acquire rounding tails that were never present in SQL Server.

This is worth stating plainly because the usual advice about NoSQL and money is that you should not, when in fact the type exists and is exact. The failure is in the conversion defaulting to double, not in MongoDB lacking the capability.

Nothing enforces the schema unless you write a validator

SQL Server rejects a row that violates a column type, a NOT NULL, a CHECK or a foreign key. MongoDB accepts whatever the application sends. The constraints in the source schema are not converted into anything, because there is no default place for them to go.

JSON Schema validators are that place, and they cover types, required fields and value ranges. They do not cover referential integrity — there are no foreign keys, so an orphaned reference is an application concern permanently. Deciding which of the source constraints to reimplement as validators, and which to accept losing, should happen before the move rather than after the first bad document.

SQL Server → MongoDB conversion notes

Engine-specific rules baked into the conversion and transfer pipeline — verified by live certification of this exact pair.

  • TINYINT is unsigned (0–255) in SQL Server — DBShifts widens it on signed targets so 128–255 don't clip.
  • UNIQUEIDENTIFIER, DATETIMEOFFSET, MONEY and NVARCHAR(MAX) all have explicit conversion rules per target.
  • Wrapped defaults like ((1)) and (N'foo') are unwrapped to portable literals.
  • Rows become flat documents; write errors surface loudly instead of being swallowed by duplicate-tolerance settings.
  • Integers beyond BSON's 8-byte range (e.g. Oracle NUMBER) become Decimal128, exact up to its 34 significant digits.
  • Dates are stored as native BSON dates (UTC instants).

Frequently asked questions

Is SQL Server to MongoDB migration production-ready in DBShifts?

SQL Server to MongoDB is in beta. It runs on real servers in the certification suite, which checks it by row counts; the content checks that certify the SQL pairs do not yet compare documents with rows. Every migration still ends with a fidelity report to audit before cutover.

Can I keep SQL Server and MongoDB in sync after the initial migration?

Yes, until you cut over. DBShifts reads SQL Server Change Tracking, which has to be enabled on the database and on each table. With zero-downtime mode on, the tracking version is captured before the first row is copied.

Go deeper

Ready to move SQL Server to MongoDB?

Set up in under two minutes. Validation and rollback included.

Start Free Migration