How much effort does a SQL Server to PostgreSQL migration take?
Schema and data transfer is often the smaller part of a SQL Server to PostgreSQL migration. A team with SQL Server databases, T-SQL stored procedures and application code that calls them is usually deciding whether the effort is worth taking on for self-hosted PostgreSQL. The honest answer is that the duration is set by three things: how much T-SQL logic must be rewritten by hand, how many application queries and drivers need changes, and how long the cutover window can be. Table and row copying with pgloader can run quickly by comparison, so a plan built around data volume alone will underestimate the work.
Start by measuring the T-SQL surface. Count stored procedures, functions, triggers, views, jobs and any use of cursors, dynamic SQL, MERGE, linked servers or CLR assemblies. Each of these needs a hand-written PL/pgSQL equivalent or a redesign, and each needs tests that prove the result. Then list every application data access layer, ORM mapping and reporting tool that talks to the database, because identifier case, quoting, paging syntax, transaction isolation defaults and date and string functions often change. Ask your application owners to confirm which queries they can test against a PostgreSQL copy before the schedule is fixed.
PostgreSQL is released under the PostgreSQL License, a permissive license similar to the BSD and MIT licenses, so the license itself does not add a per-core fee to the migration. This page covers the work involved and does not go further into licensing terms, which your legal or procurement team should review against your own agreements. For the cutover window, agree in writing how long writes can be paused, who approves the switch, and how you will roll back if validation fails. Those decisions, more than the copy speed, determine whether the project fits your calendar.
Which SQL Server features map to PostgreSQL and which do not
This table compares common SQL Server capabilities with their PostgreSQL equivalents and notes which items pgloader discovers and transfers on its own. Use the discovery column to size manual work, and confirm every type and object mapping against your own schema before planning the cutover.
| Source capability | Automatic with pgloader | PostgreSQL equivalent and migration notes |
|---|---|---|
| Tables and columns | true | Tables are discovered and created, but column types must be checked against your schema. Confirm each type mapping for your data before relying on it. |
| Indexes and primary keys | true | Discovered and recreated. Confirm index types and clustered index behavior, since PostgreSQL has no clustered index equivalent. |
| Foreign keys and unique constraints | true | Discovered and recreated. Review constraint names and deferrability, and check referential rules against application behavior. |
| Identity columns | false | Map to identity or sequence defaults. Reset sequence values after the data load so new inserts do not collide. |
| Views | false | Recreate by hand. Rewrite T-SQL view definitions into PostgreSQL SQL and test each view's results. |
| Stored procedures and functions | false | Rewrite T-SQL as PL/pgSQL or move logic into the application. Expect this to be the largest manual effort. |
| Triggers | false | Rewrite as PostgreSQL trigger functions. Confirm timing and row or statement scope match the original. |
| SQL Server Agent jobs | false | Replace with cron, systemd timers, pg_cron or an external scheduler. Confirm each job's schedule, owner and failure alerting. |
| Linked servers | false | No direct equivalent. Use foreign data wrappers or move cross-server queries into the application, and confirm credentials handling. |
| Schemas and collations | false | Schemas map across with renaming review. Collations do not map one to one, so confirm sort order and case sensitivity with your team. |
Which documented tools move the schema and data
A SQL Server to PostgreSQL migration uses one tool to carry schema and data across, and several PostgreSQL-side tools to check, script and restore the result. Each card below covers one tool or check, and the pilot is the point where you confirm each one against your own environment.
pgloader as the migration engine
pgloader is the open-source tool named for this path. It connects to the SQL Server source, discovers tables, indexes and keys, creates the matching objects in PostgreSQL and copies the rows in one run. Because discovery is automatic, the first pilot run shows you what it created and what it skipped, and that output should be reviewed table by table before any further work begins.
Confirming pgloader's SQL Server support
Before the pilot, confirm the pgloader version you will use, its SQL Server source options and how it maps data types, defaults, identity columns and constraints. Check these against the pgloader documentation and a test run on a copy of your database, not against memory or a forum post. Record the exact version and command options in your migration runbook so the pilot and the production run behave the same way.
psql for scripts and checks
psql is the PostgreSQL command-line client and the tool your team will use to run rewritten T-SQL replacements, post-load SQL, row count checks and privilege grants against the target. Keep every script in version control and run it with psql in a fixed order, so the same sequence can be repeated for each rehearsal and for the final cutover.
PostgreSQL documentation for the target
The PostgreSQL documentation describes how each data type, constraint, index and sequence behaves on the target. Use it to review the objects pgloader creates, especially where SQL Server semantics differ, such as collation, case sensitivity, and how stored procedures, triggers and functions map to PL/pgSQL. Assign a named reviewer for each object class so that decisions are documented, not left to the tool's defaults.
Upgrading docsRestore and backup tooling
Plan a restore path before the cutover. A logical dump of the loaded target, taken with the PostgreSQL dump tools, gives you a known-good copy to restore into a clean server during rehearsals. Confirm the exact dump and restore commands, their options and the restore time for your data volume during the pilot, since no timing figures apply to your database until you measure them.
Row counts and data comparison
Verification relies on comparing the source and target after each load. Compare row counts per table, checksums on key columns, and sample rows for types that often change, such as datetime, decimal, money and text with special characters. Store the comparison output with the rehearsal record so that each cutover decision can be traced to evidence, and name who signs off on any difference.
Which T-SQL code must be rewritten by hand
Stored procedures, user-defined functions, triggers, views with T-SQL logic and SQL Server Agent jobs will not transfer as-is, so plan for a hand-rewrite of the procedural layer before the data load is scheduled. pgloader moves tables, indexes, keys and data, but T-SQL business logic is written in a different dialect. Expect rewrites in PL/pgSQL or in the application for TOP clauses (which become LIMIT or FETCH FIRST), MERGE statements, cursors, temporary tables (which need a different lifetime model in PostgreSQL), TRY/CATCH error handling, @@IDENTITY and SCOPE_IDENTITY() calls, and dynamic SQL built with sp_executesql. Agent jobs are not database objects that pgloader migrates, so each job needs a new scheduler, such as cron, pg_cron or an orchestrator you already run, and an owner who knows what it does. Confirm the PostgreSQL version you target against the supported list in the PostgreSQL versioning policy before you choose language features that depend on it.
Start with an inventory. Query the SQL Server catalog views for every procedure, function, trigger, view and job, record which tables and linked servers each one touches, and note any use of CLR assemblies, cross-database calls, or Service Broker, which have no direct PostgreSQL equivalent. Then classify each object: simple read queries and views are usually low effort, while procedures that combine cursors, dynamic SQL, transactions and error handling are high effort and may be better moved into the application. Record the business owner and the callers of each object, because an unused procedure is often cheaper to retire than to convert. Ask any partner for this inventory in writing, with a count per object type and a complexity class, before agreeing on rewrite effort.
Test each rewritten object against the same inputs used in production. Capture input parameter sets and expected outputs from SQL Server, including edge cases such as NULL handling, empty result sets and collation-sensitive string comparisons, then run the PL/pgSQL version against the migrated data and compare row counts, checksums and returned values. Pay attention to transaction boundaries, because PostgreSQL procedures and functions behave differently in commit and rollback handling, and confirm the error paths return the codes the application expects. Keep the rewritten logic under version control next to the inventory, so each cutover rehearsal can be repeated and each change traced to a test result.
Where licensing savings come from and how to size them
The SQL Server license is the line item most teams expect to disappear, but the amount depends on how the license was bought and whether Software Assurance is attached. Software Assurance is an optional maintenance agreement that grants version upgrade rights and some benefits, and it is often renewed on a schedule separate from the server licenses. Confirm whether the agreement is active, when it renews, and whether any cost is tied to it that you could stop paying after cutover.
- Perpetual licenses: Once cutover finishes and the instances are retired, the license may be reusable for other workloads or eligible for resale or transfer, depending on your agreement. Check whether the rights are actually released or simply unused.
- Software Assurance renewals: Find the renewal date and notice period. Stopping renewal before cutover can leave you without upgrade rights you still need during the parallel run.
- Downgrade and dual-running rights: Ask whether your agreement allows SQL Server to keep running during the parallel period and what the terms are for read-only fallback.
- Recurring after cutover: PostgreSQL carries no license fee, but the staff time to run it, backups, monitoring and upgrades all continue as ongoing work.
Before sizing savings, ask your licensing advisor to confirm the license entitlements, the Software Assurance end date and any transfer or retirement terms in writing.
The licensing model determines what scales with hardware. Under a per-core model, cost follows the physical or virtual cores assigned to the SQL Server instance, and core counts are often subject to minimum license rules per server. Under a per-server model with client access licenses, cost follows server count and user or device access. Each model reacts differently to consolidation, virtualization and capacity growth, so the savings calculation should follow your model rather than a generic assumption.
- Core counts and minimums: Record the cores licensed on each instance, including any minimum core requirements that apply per server.
- Virtualization and host rules: Check how virtual machines and host-level licensing are counted, since a move that changes host density can change the license footprint.
- Client access licenses: If your model uses them, list the users or devices covered and whether any are shared with other products.
- Recurring after cutover: Hardware for PostgreSQL servers, replicas and backup targets is a recurring cost that replaces the SQL Server hardware you retire.
Ask your licensing advisor to confirm how your current core counts and minimums are counted and what happens to unused licenses when instances are removed.
Licensing is only part of the bill. Teams also pay for the hardware, storage, backup software, monitoring tools and vendor support that surround SQL Server, and some of these contracts are tied to the database even when the license is not. Some support contracts cover the operating system or hypervisor under the same agreement, so you may keep paying for them after cutover. Separate the database-specific costs from shared costs before counting anything as saved.
- Database-specific support: Identify support contracts that are only needed because SQL Server runs. These are the most likely to stop after cutover.
- Shared platform contracts: Operating system, hypervisor and storage support often continue because other workloads still use them.
- Backup and monitoring tools: Some backup agents or monitoring products are priced per database or instance. Check whether replacing them with open-source tools changes their cost.
- Recurring after cutover: Staff time for administration, on-call coverage, backup testing and PostgreSQL upgrades continues, and should be counted in the comparison.
Ask your procurement and licensing advisors to confirm which contracts end at cutover, which have notice periods, and which are shared with systems that stay in place.
A useful comparison lists each current cost, marks it as one-time or recurring, and marks whether it stops, shrinks or continues after cutover. The one-time costs include migration work, testing, parallel running and any early termination fees. Recurring costs on the PostgreSQL side include staff time, infrastructure, backups, monitoring and upgrades. Build the model from your own invoices and contract terms, and keep assumptions visible so a reviewer can change them.
- One-time costs: Migration work, schema conversion, testing, parallel running, training and any contract exit fees.
- Recurring costs on SQL Server: License renewals, Software Assurance, support and infrastructure, listed by contract end date.
- Recurring costs on PostgreSQL: Staff time, hardware, storage, backups, monitoring and planned major upgrades.
- Timing: Show when each cost starts and stops, since parallel running can delay the point where savings begin.
- Illustrative example: A team that runs two SQL Server instances on a shared host might find that only one contract ends at cutover, while host support continues for other workloads.
Review the finished model with your licensing advisor and finance team before you rely on any savings figure.
How a phased cutover runs from inventory to decommission
The sequence moves SQL Server workloads to PostgreSQL in stages, so each stage produces evidence that the next one can rely on and a rollback path stays open until the cutover is proven. Duration depends on the inventory, not on a fixed schedule.
Inventory databases, objects and connections
Before any conversion, list every SQL Server instance, database, schema, table, view, stored procedure, function, trigger, SQL Agent job, linked server and application that connects to it, including reporting tools and ETL jobs. Record which applications use which connection strings, drivers and login methods. The step is done when the team can name the owner of each database and each consuming application, and when every object has been classified as migrate, rewrite or retire.
Convert schema and run a pilot load
Run pgloader against a copy of the source to discover tables, indexes, keys and defaults, and to map SQL Server types to PostgreSQL types. Load the result into a non-production PostgreSQL cluster built the same way as the target will be. Review the generated DDL, because automatic conversion does not handle T-SQL logic. The step closes when the pilot schema loads without errors, row counts match the source for each table, and the team has a written list of type mappings and objects that need manual work.
Rewrite T-SQL and application queries
Work through stored procedures, functions, triggers, views and jobs that pgloader does not convert, and rewrite them in PL/pgSQL or move the logic into the application. Update application queries, driver settings and transaction handling for PostgreSQL behavior, including identifier case, sequence use and NULL handling. Each rewritten object should be tested against the same inputs as the original. The step is complete when every object on the inventory has a tested replacement or an approved retirement decision.
Run both systems in parallel
Keep SQL Server as the system of record while the PostgreSQL copy receives the same changes, either through replicated writes, a change feed or repeated loads that the team controls. Compare results for key reports, transactions and batch outputs on a schedule agreed in advance. Investigate every mismatch and record its cause before continuing. The parallel run is finished when a defined set of reconciliation checks has passed over the agreed period and the team signs off on the differences that remain.
Cut over with a verified rollback path
Freeze writes on SQL Server, apply the final changes to PostgreSQL, run the reconciliation checks again, and repoint applications using the connection changes prepared earlier. Keep SQL Server available in read-write form and keep the reverse path documented, so that the team knows how changes made on PostgreSQL after cutover would be returned if a serious fault appears. The step closes when the agreed checks pass on the production PostgreSQL database and the application owners confirm normal operation.
Decommission SQL Server after restores are proven
Keep the SQL Server instance in a read-only or standby state for the period agreed during planning. During that time, take a backup of the PostgreSQL databases, restore it to a separate server, and check the restored data against the expected results. Only after restores are proven and the rollback window has closed should SQL Server licenses be retired, its backups archived under the retention policy and its access removed. The step is done when the restore test has passed, the decommission record is signed off, and licensing changes are confirmed with the vendor or licensing advisor.
How the migration phases and cutover gates connect
The diagram starts at the inventory of SQL Server objects and runs through a pilot load with pgloader, then T-SQL and application rewrites, verification and a parallel run. The go or no-go gate is the key hand-off: a go moves to cutover and then decommission, while a no-go returns the team to SQL Server as the rollback path. Check at the gate that data checks, rewritten code and application tests have all passed before any production traffic moves.
Migration phases and the go or no-go gate, with rollback to SQL Server.
What drives the cost and duration of the move
This table lists the factors that change how much work a SQL Server to PostgreSQL move takes and how long it runs. Read each row as a question to answer in your scope before asking for a quote. The main takeaway is that the amount of T-SQL, the number of connections and the downtime window the business accepts usually shape the schedule more than the row count does.
| Driver | Why it matters | What to ask for in a quote |
|---|---|---|
| Number and size of databases | Each database needs its own schema discovery, type mapping, data load and validation, so effort grows with the count even when individual databases are small. | A per-database inventory with schema object counts, and whether databases share schemas, logins or cross-database queries. |
| Volume of T-SQL and stored logic | Stored procedures, functions, triggers and views are rewritten by hand in PL/pgSQL, and this is usually the largest single block of work. | A count of procedures, functions, triggers and views by type, with a flag for those using CLR, cursors or dynamic SQL. |
| Application connections and changed SQL | Drivers, ORM mappings and hand-written queries that use T-SQL syntax, identity columns or quoting must change and be retested. | A list of applications and connection strings, the drivers they use, and an estimate of statements that need changes from your code owners. |
| Data volume and accepted downtime window | Larger tables and a short cutover window push the team toward initial bulk load plus change capture, which adds design and test work. | Total data size per database, largest tables, the outage window the business accepts and the rollback point you require. |
| SQL Server Agent jobs and linked servers | Scheduled jobs, alerts, database mail and linked server queries have no direct equivalent and must be rebuilt on a scheduler you run. | An inventory of Agent jobs, their schedules and dependencies, and every linked server and the systems behind it. |
| Required parallel run length | Running both systems side by side for reconciliation and reporting extends the project and needs data comparison tooling and a sign-off process. | The length of parallel run you require, the reconciliation method, and who signs off on each comparison result. |
| Authentication and TLS on the new cluster | Moving from Windows integrated logins to PostgreSQL roles, SCRAM password authentication and TLS requires directory integration decisions and client changes. | Confirmation of the target authentication method, certificate authority, directory integration and which client libraries need configuration changes. |
What usually goes wrong in SQL Server to PostgreSQL migrations
Most failed SQL Server to PostgreSQL migrations do not fail at the copy step. They fail afterward, when data looks loaded but behaves differently, when stored logic or application code assumes SQL Server rules, or when nobody has proven a restore. The cards below cover the risks to plan for and the checks that catch them before cutover.
Silent collation and case differences
SQL Server collations are often case-insensitive and accent-insensitive, so comparisons, sorting and uniqueness checks can return different results in PostgreSQL, where default collations are case-sensitive. Values that matched a WHERE clause in SQL Server may stop matching after load, and sort orders can shift for the same rows. Compare sample result sets from both databases for key queries, and confirm the target collation and encoding with a validation query on distinct and sorted values before you approve the schema.
Data type edge cases
Types such as datetime, money, bit, nvarchar(max) and uniqueidentifier map to different PostgreSQL types with different ranges, precision and rounding. A pgloader type mapping may be correct for most columns and still truncate or shift a few, especially date values near the limits and decimal scales. Run row counts and per-column checksums for every table, and review the mapping for each column that stores money, time or identifiers.
Identity and sequence values not reset
Bulk loads that insert explicit identity values do not advance the PostgreSQL sequence behind the column. The first insert after cutover then collides with an existing primary key, often in the middle of business hours. Compare the maximum value of each key column with the current sequence value, reset each sequence to the loaded maximum, and test an insert on every table in the staging copy before the cutover window.
Stored logic and transaction behavior
T-SQL procedures, triggers and functions must be rewritten by hand, and some behave differently under PostgreSQL rules. A function that runs inside an explicit transaction in SQL Server may fail or commit at a different point in PostgreSQL, and error handling that depends on TRY/CATCH blocks or @@ROWCOUNT has no direct equivalent. Build a test case for each procedure that checks outputs, rollback behavior and error paths against the same input data.
Application code tied to SQL Server
Application queries often rely on SQL Server features such as TOP without ORDER BY, bracketed identifiers, OFFSET FETCH syntax, implicit conversions between strings and numbers, or ORM settings for a specific dialect. These can fail with errors, or worse, return different rows without failing. Search the codebase and query logs for T-SQL-specific syntax, then run the application's integration tests against PostgreSQL with production-like data before the application team signs off.
Backups and restores never proven
A migration plan that lists backups but never restores one leaves the rollback path untested. Confirm that a full copy of the PostgreSQL target can be restored from a base backup and archived WAL files to a chosen point in time, that the restore completes within the window the business accepts, and that the SQL Server source remains available for rollback until the cutover is accepted. Schedule the restore drill before the cutover date, not after it.
Read the sourceQuestions buyers ask before moving SQL Server to PostgreSQL
What drives the cost of moving SQL Server to PostgreSQL?
The cost depends mostly on how much T-SQL sits outside the database schema, how many applications connect to it, and how much validation the business requires before cutover. Schema and data movement with pgloader is the smaller share of effort in most cases. The larger items are rewriting stored procedures, functions, triggers and jobs in PL/pgSQL, changing application queries and drivers, building a test harness that compares results, and planning the cutover window. Cost is one-time for the migration itself, while the new platform adds recurring costs for hosting, backups, monitoring, patching and staff time. Ask any partner for a quote that separates code conversion, application changes, testing, cutover support and post-cutover handover, and that states which items depend on your inventory.
How long does a SQL Server to PostgreSQL migration take?
Duration is set by the amount of code to rewrite and the number of systems that must be retested, not by the size of the data alone. A database with few programmable objects and one application can move faster than a database with hundreds of procedures spread across several services. Plan time for discovery, a proof of concept on a copy, conversion of T-SQL objects, application testing, at least one full rehearsal of the cutover, and the cutover itself. Phased moves take longer overall but reduce the risk of a single large switch. Ask for a schedule tied to a written inventory, and confirm which milestones your change advisory board must approve.
What must our internal team provide before a migration starts?
A migration moves faster when the internal team supplies accurate inputs early. Prepare a complete inventory of databases, schemas, tables, views, stored procedures, functions, triggers, SQL Server Agent jobs, linked servers and logins. Provide read access to the source instances, a non-production target, and a copy of production-like data for testing that your data rules allow. Name an owner for each application that connects to the database, and make sure they can describe the queries they run. Agree on test data, acceptance criteria, a rollback plan and change windows with the business. Missing application owners are one of the most common causes of delay.
Can our own team migrate SQL Server to PostgreSQL without outside help?
A capable database team can run a small migration alone, especially when the schema is simple and the team already knows PostgreSQL. The risk rises with the number of T-SQL objects, the number of dependent applications and the strictness of your data and uptime requirements. Look at your team's experience with PL/pgSQL, data type mapping, query plan review and cutover rehearsal. An outside partner can help with assessment, code conversion, test design or cutover support, and the work can be scoped in writing so responsibilities are clear. Whichever route you choose, your staff still needs to own the target platform after cutover.
Which parts does pgloader handle automatically, and which need manual work?
pgloader connects to SQL Server, reads table definitions, and creates matching tables in PostgreSQL. It can migrate data and carry over many indexes, primary keys, foreign keys and default values, and it applies type mappings that you should review for each column. It does not convert T-SQL stored procedures, functions, triggers or views into PL/pgSQL, and it does not rewrite application SQL. Expect manual work for identity and sequence behavior, collation and case sensitivity, date and money types, computed columns, SQL Server Agent jobs, and any cross-database or linked server queries. Check the generated schema against the source before loading production data, and confirm the pgloader version and options against its current documentation.
What happens to licensing and support after cutover?
PostgreSQL is released under the PostgreSQL License, a permissive open source license similar to the BSD or MIT licenses, so there is no per-core or per-server license fee to the database project itself. Your costs shift to infrastructure, operations, support contracts from any vendor you choose, and staff time. Confirm what your existing SQL Server licenses, software assurance and support agreements cover during parallel running and after decommissioning, because contract terms often set when savings begin. Plan support ownership for patching, backups, monitoring and upgrades. PostgreSQL supports each major version for 5 years after its initial release, so schedule upgrades within that window.
Should we move in phases or cut over all databases at once?
Phased cutover reduces risk when several applications depend on the same SQL Server instance, because each application can move after its code and tests are ready. A single cutover can work for a small estate with few dependencies, but it requires a longer rehearsal and a clear rollback. In either approach, keep both systems available during a defined parallel period, decide how writes are handled during the switch, and agree on the data validation checks that must pass before sign-off. Ask any partner to show how the plan handles application dependencies, failed validation and rollback.
How DeployOpen scopes and delivers the migration
DeployOpen plans, builds, tests and hands over SQL Server to PostgreSQL migrations inside infrastructure you control, with the scope agreed in writing before work starts. The work follows the same arc on every engagement: scope the source estate, build and rehearse the move, hand over documented results, then support the platform afterward.
How we scope
- Inventory the SQL Server instances, databases, SQL Agent jobs, linked servers and T-SQL objects that the migration must cover.
- Agree in writing which schemas, stored procedures, triggers and application connections are in scope and which are retired.
- Define the cutover window, acceptable downtime and the rollback position with your application and database owners before build starts.
How we build
- Run pgloader against a copy of the source to review discovered tables, indexes, keys and type mappings before any production load.
- Rewrite T-SQL procedures, functions and triggers by hand into PL/pgSQL, with each change recorded and reviewed against the original logic.
- Rehearse the full load and cutover at least once, comparing row counts, constraints and sample query results between source and target.
How we hand over
- Deliver a migration runbook covering load order, sequence resets, cutover steps, validation queries and the rollback procedure.
- Document the type mapping decisions, rewritten code and any SQL Server features that were replaced rather than carried across.
- Walk your database, application and security teams through the target configuration, authentication settings and backup arrangements.
How we support
- Support the first production period with an agreed escalation path for issues found after cutover, as set out in the written scope.
- Offer ongoing support, upgrades and continuous testing as a retainer once the platform is in regular operation.
- Confirm with us which post-handover items, such as tuning, monitoring and PostgreSQL minor release updates, sit inside or outside the retainer.

