Use case
Migrate an Access database to SQL Server with SSMA
The database keeps growing, more people use it, corruption keeps coming back: a common answer is to keep Access for the forms and move the data to SQL Server. Microsoft provides a free tool for this, SQL Server Migration Assistant (SSMA) for Access. It moves the tables and the data; it does not touch forms, reports or VBA code. Here are the steps, then what breaks afterwards.
What SSMA does, and what it doesn't
SSMA reads an Access 97 or later database and converts it for SQL Server 2019 or later (on Windows or Linux), Azure SQL Database or Azure SQL Managed Instance. It recreates tables, indexes, foreign keys, default values and validation rules (as CHECK constraints), then copies the data.
| In the Access database | After SSMA |
|---|---|
| Tables, columns, indexes, relationships | Recreated in SQL Server |
| Select queries | Most become views |
| Parameter queries, crosstab queries | Not converted |
| Action queries (update, append, delete) | Not migrated |
| Forms, reports, macros, VBA modules | Not converted: they stay in Access |
"Not migrated" does not mean lost: a query that stays in Access keeps running, but against tables linked to SQL Server. The Access application remains, and that is what has to work after the migration.
Before you run SSMA
- Work on a copy of the Access database, and back up the target SQL Server database too.
- Check that the database works: a form already broken in Access will still be broken after the migration, and the migration will get the blame.
- Remove workgroup security (
.mdwfile) from old.mdbdatabases: SSMA cannot migrate a database that uses it. - Give every table a primary key: a table without a unique index cannot be updated once it is in SQL Server.
- Look for out-of-range dates: SQL Server's
datetimetype starts on 1 January 1753, while Access accepts dates from the year 100. A year typed "0195" instead of "1995" is enough. - Find names that are SQL Server reserved words, or that contain special characters: rename them, or bracket them in every query that uses them.
The steps in SSMA
- Create a project (File › New Project) and choose the target: SQL Server or Azure SQL.
- Add the Access database (Add Databases).
- Connect to SQL Server (Connect to SQL Server), preferably with Windows authentication.
- Produce the assessment report (Create Report): it lists what will not convert, object by object.
- Convert the schema (Convert Schema): nothing is created on the server yet, the conversion stays in the project. Read the error list.
- Load into the target database (Synchronize with Database): tables and views are created.
- Migrate the data (Migrate Data).
- Link the tables (Link): SSMA keeps a copy of each original Access table and replaces it with a table linked to SQL Server.
Pitfalls after the migration
- Slow queries: a query that calls a VBA function, or an Access function SQL Server does not know, makes Access pull the table down to filter it on the PC. Fix: pass-through query, view or stored procedure.
- An empty AutoNumber right after
AddNew: in SQL Server, theIDENTITYvalue only exists once the record has been saved. - Error 3622:
OpenRecordseton a SQL Server table with anIDENTITYcolumn requires thedbSeeChangesoption. - A form where you can no longer add records: its record source must include every column of at least one unique index of the table.
- Hyperlinks turned into text: SQL Server has no such type, the column becomes
nvarchar(max). - A PC without the ODBC driver: the linked tables do not open, with error 3151.
OpenRecordset raises error 3622, and the number is empty before Update.Set rs = CurrentDb.OpenRecordset("Invoices", dbOpenDynaset)
rs.AddNew
rs!CustomerID = 42
MsgBox rs!InvoiceNo ' empty with SQL Server
rs.UpdatedbSeeChanges, then read the number from the record that has just been saved.Set rs = CurrentDb.OpenRecordset("Invoices", dbOpenDynaset, dbSeeChanges)
rs.AddNew
rs!CustomerID = 42
rs.Update
rs.Bookmark = rs.LastModified
MsgBox rs!InvoiceNo ' filled in
Know what the database contains before migrating
The Auscult diagnostic does not migrate anything. Before SSMA, it tries every form, every report and every query in the Access on your PC, and tells you what works and what already fails, with the cause: there is no point migrating a fault. The full report also sizes the migration: simple elements or elements with code, lines of code, heaviest modules — the basis for a quote. See the pre-migration audit and, for the overall approach, migrating an Access application.
Sources
- SQL Server Migration Assistant for Access (AccessToSQL) — Microsoft Learn
- Installing SQL Server Migration Assistant for Access — Microsoft Learn
- Preparing Access Databases for Migration — Microsoft Learn
- Incompatible Access Features — Microsoft Learn
- Converting Access Database Objects — Microsoft Learn
- Link Access Applications to SQL Server and Azure SQL Database — Microsoft Learn
- Access connectivity components for SSMA — Microsoft Tech Community