Обсуждение: MSSQL to PostgreSQL Migration

Поиск
Список
Период
Сортировка

MSSQL to PostgreSQL Migration

От
Datta D
Дата:
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta

Re: MSSQL to PostgreSQL Migration

От
Alan Piszcz
Дата:
One is pgloader, syntax is different.




From: Datta D <dattadeshpande.it@gmail.com>
Sent: Sunday, January 1, 2023 1:11 PM
To: pgsql-admin@postgresql.org <pgsql-admin@postgresql.org>
Subject: MSSQL to PostgreSQL Migration
 
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta

RE: MSSQL to PostgreSQL Migration

От
Pascal CROZET
Дата:

Hi Datta D

 

You can use ora2pg that can help you to migrate also from MySql.

Moves Oracle and MySQL database to PostgreSQL

 

I’ve use it to migrate in cloud IaaS from Oracle to PG 14

 

From: Datta D <dattadeshpande.it@gmail.com>
Sent: Sunday, January 1, 2023 7:12 PM
To: pgsql-admin@postgresql.org
Subject: MSSQL to PostgreSQL Migration

 

Dear Admins

 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.

 Can you please suggest a related open-source tool for migrating all objects and data?

 

Thanks

Datta

RE: MSSQL to PostgreSQL Migration

От
Pascal CROZET
Дата:

Datta D.

 

I’ve read MySql instead of MsSql :/ Sorry. I prefer to name it as SqlServer, to avoid this issue.

In this page, you can found pgloader or Sqlserver2pgsql as open source tools

 

From: Pascal CROZET
Sent: Monday, January 2, 2023 9:12 AM
To: Datta D <dattadeshpande.it@gmail.com>; pgsql-admin@postgresql.org
Subject: RE: MSSQL to PostgreSQL Migration

 

Hi Datta D

 

You can use ora2pg that can help you to migrate also from MySql.

Moves Oracle and MySQL database to PostgreSQL

 

I’ve use it to migrate in cloud IaaS from Oracle to PG 14

 

From: Datta D <dattadeshpande.it@gmail.com>
Sent: Sunday, January 1, 2023 7:12 PM
To: pgsql-admin@postgresql.org
Subject: MSSQL to PostgreSQL Migration

 

Dear Admins

 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.

 Can you please suggest a related open-source tool for migrating all objects and data?

 

Thanks

Datta

Re: MSSQL to PostgreSQL Migration

От
Dan Smith
Дата:
The AWS schema Conversion Tool might be helpful for MS SQL Server migrations to Postgres (https://docs.aws.amazon.com/SchemaConversionTool/latest/userguide/CHAP_Welcome.html).  It will at least help you determine level of effort and which objects might need refactoring.


Best regards,

Dan Smith

Re: MSSQL to PostgreSQL Migration

От
Gilles Darold
Дата:
Le 02/01/2023 à 09:22, Pascal CROZET a écrit :
@font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4;}@font-face {font-family:Calibri; panose-1:2 15 5 2 2 2 4 3 2 4;}@font-face {font-family:Consolas; panose-1:2 11 6 9 2 2 4 3 2 4;}@font-face {font-family:Roboto; panose-1:2 0 0 0 0 0 0 0 0 0;}p.MsoNormal, li.MsoNormal, div.MsoNormal {margin:0cm; margin-bottom:.0001pt; font-size:12.0pt; font-family:"Times New Roman",serif;}a:link, span.MsoHyperlink {mso-style-priority:99; color:#0563C1; text-decoration:underline;}a:visited, span.MsoHyperlinkFollowed {mso-style-priority:99; color:#954F72; text-decoration:underline;}p.terminal, li.terminal, div.terminal {mso-style-name:terminal; mso-style-link:"terminal Car"; margin:0cm; margin-bottom:.0001pt; background:black; font-size:9.0pt; font-family:Consolas; color:white;}span.terminalCar {mso-style-name:"terminal Car"; mso-style-link:terminal; font-family:Consolas; color:white; background:black;}p.msonormal0, li.msonormal0, div.msonormal0 {mso-style-name:msonormal; mso-margin-top-alt:auto; margin-right:0cm; mso-margin-bottom-alt:auto; margin-left:0cm; font-size:12.0pt; font-family:"Times New Roman",serif;}span.EmailStyle20 {mso-style-type:personal; font-family:"Calibri",sans-serif; color:#1F497D;}span.EmailStyle21 {mso-style-type:personal-reply; font-family:"Calibri",sans-serif; color:#1F497D;}.MsoChpDefault {mso-style-type:export-only; font-size:10.0pt;}div.WordSection1 {page:WordSection1;}

Datta D.

 

I’ve read MySql instead of MsSql :/ Sorry. I prefer to name it as SqlServer, to avoid this issue.

In this page, you can found pgloader or Sqlserver2pgsql as open source tools


Actually, I need it for a customer migration at MigOps, so it does since few days:


commit 7d9796b2949982867925eaebaa112bf5520403d5
Merge: 4220916 c911903
Author: Gilles Darold <gilles@darold.net>
Date:   Tue Nov 29 21:11:58 2022 +0100

    Add SQL Server migration to Ora2Pg. Most of the SQL Server objects are
    supported as well as data export. Translation of the TSQL stored
    procedures to plpgsql is complicated because of the lack of statement
    separator in TSQL but as usual Ora2Pg is doing is best to do as much
    work as possible. Migration assessment is also possible with SQL Server
    database. There is some dedicated configuration directives added to
    ora2Pg.conf.


I have planned to publish a new release and an announcement this month. Note that it is a new feature that needs to be polished, your feed back will be welcome.


If you can't wait the new release you can download the development code using git or as an archive from https://github.com/darold/ora2pg/archive/refs/heads/master.zip

It just works like an Oracle migration, the most complicated thing is to connect Ora2Pg to the remote SQL Server database :-)

There is only 2 new configuration directive related to this RDBMS:


  Control SQL Server export behavior
    DROP_ROWVERSION
        PostgreSQL has no equivalent to rowversion datatype and feature, if
        you want to remove these useless columns, enable this directive.
        Columns of datatype 'rowversion' or 'timestamp' will not be
        exported.

    CASE_INSENSITIVE_SEARCH
        Emulate the same behavior of MSSQL with case insensitive search. If
        the value is citext it will use the citext data type instead of
        char/varchar/text in tables DDL (Ora2Pg will add a CHECK constraint
        for columns with a precision). Instead of citext you can also set a
        collation name that will be used in the columns definitions. To
        disable case insensitive search set it to: none.

Look at documentation (README) on how to migrate a SQL Server database with Ora2Pg.


Best regards,

-- 
Gilles Darold
MigOps Inc
http://www.migops.com/

Re: MSSQL to PostgreSQL Migration

От
Samed YILDIRIM
Дата:
Hi Datta,

What objects do you exactly need to migrate? Tables, views, functions, indexes, procedures etc. Depending on object types, I can recommend multiple options. Unfortunately, I don't know any good solution that can convert all T-SQL code to pl/pgsql.

Best regards.
Samed YILDIRIM


On Sun, 1 Jan 2023 at 20:12, Datta D <dattadeshpande.it@gmail.com> wrote:
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta

Re: MSSQL to PostgreSQL Migration

От
Datta D
Дата:
Hi Samed
 I have all type of objects tables,views, functions, procs etc with Data in table SqlServer database, which I am looking for migrating it to Postgresql with OpenSource tools.

Thanks
Datta

On Mon, Jan 9, 2023 at 5:59 PM Samed YILDIRIM <samed@reddoc.net> wrote:
Hi Datta,

What objects do you exactly need to migrate? Tables, views, functions, indexes, procedures etc. Depending on object types, I can recommend multiple options. Unfortunately, I don't know any good solution that can convert all T-SQL code to pl/pgsql.

Best regards.
Samed YILDIRIM


On Sun, 1 Jan 2023 at 20:12, Datta D <dattadeshpande.it@gmail.com> wrote:
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta

Re: MSSQL to PostgreSQL Migration

От
Gurudutt Dhareshwar
Дата:
Hi Datta ,

You can extract the data using the SSM Tool right click on the DB and use the extract wizard once done you can use a open source tool like SQLline to change the code. and then create them in Postgres .

For data you can move it using the SQL tool itself or take a BCP Out and then insert using the psql -d option . 

On Wed, Jan 11, 2023 at 7:14 PM Datta D <dattadeshpande.it@gmail.com> wrote:
Hi Samed
 I have all type of objects tables,views, functions, procs etc with Data in table SqlServer database, which I am looking for migrating it to Postgresql with OpenSource tools.

Thanks
Datta

On Mon, Jan 9, 2023 at 5:59 PM Samed YILDIRIM <samed@reddoc.net> wrote:
Hi Datta,

What objects do you exactly need to migrate? Tables, views, functions, indexes, procedures etc. Depending on object types, I can recommend multiple options. Unfortunately, I don't know any good solution that can convert all T-SQL code to pl/pgsql.

Best regards.
Samed YILDIRIM


On Sun, 1 Jan 2023 at 20:12, Datta D <dattadeshpande.it@gmail.com> wrote:
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta


--
Regards,

Gurudutt Dhareshwar

Re: MSSQL to PostgreSQL Migration

От
Alex Aquino
Дата:
I'd suggest looking into https://babelfishpg.org/
'Babelfish understands the SQL Server wire-protocol and T-SQL, the Microsoft SQL Server query language, so you don’t have to switch database drivers or re-write all of your application queries.'

This was formerly an AWS project that they fully opensourced (https://aws.amazon.com/rds/aurora/babelfish/).  
  
Dependening on the specifics of your usecase, it might help in your overall solution.

Regards,
Alex




On Wed, Jan 11, 2023 at 9:21 PM Gurudutt Dhareshwar <gurudutt.dhareshwar@gmail.com> wrote:
Hi Datta ,

You can extract the data using the SSM Tool right click on the DB and use the extract wizard once done you can use a open source tool like SQLline to change the code. and then create them in Postgres .

For data you can move it using the SQL tool itself or take a BCP Out and then insert using the psql -d option . 

On Wed, Jan 11, 2023 at 7:14 PM Datta D <dattadeshpande.it@gmail.com> wrote:
Hi Samed
 I have all type of objects tables,views, functions, procs etc with Data in table SqlServer database, which I am looking for migrating it to Postgresql with OpenSource tools.

Thanks
Datta

On Mon, Jan 9, 2023 at 5:59 PM Samed YILDIRIM <samed@reddoc.net> wrote:
Hi Datta,

What objects do you exactly need to migrate? Tables, views, functions, indexes, procedures etc. Depending on object types, I can recommend multiple options. Unfortunately, I don't know any good solution that can convert all T-SQL code to pl/pgsql.

Best regards.
Samed YILDIRIM


On Sun, 1 Jan 2023 at 20:12, Datta D <dattadeshpande.it@gmail.com> wrote:
Dear Admins
 I am looking for a reliable open-source tool for migrating MSSQL server to Postgresql on prem cloud.
 Can you please suggest a related open-source tool for migrating all objects and data?

Thanks
Datta


--
Regards,

Gurudutt Dhareshwar

Re: MSSQL to PostgreSQL Migration

От
Holger Jakobs
Дата:
Am 12.01.23 um 04:21 schrieb Gurudutt Dhareshwar:
> For data you can move it using the SQL tool itself or take a BCP Out 
> and then insert using the psql -d option .


Actually, bcp.exe does not do a very good job. It cannot make a 
difference between an empty string and a NULL value, for instance.

If you try to export in tab-separated format 
(https://www.iana.org/assignments/media-types/text/tab-separated-values), 
carriage returns, newlines, tab character will all mess up the output. 
And contained backslashes are not doubled as necessary for PG's copy 
statement.

In case your tables aren't too large, you can export via PowerShell 
keeping the differences between NULL and empty string. The way via JSON 
may be a bit slow and heavy on memory, though.


### Code for Powershell

install-module sqlserver

$SqlParams = @{
   ServerInstance = 'server_name'
   UserName = 'user_name'
   Password = 'very_secret'
   Database = 'db_name'
}

$tableName = 'whatever_tablename'
(invoke-sqlcmd @SqlParams -query "Select * from $tableName" | 
select-object * -excludeproperty 
itemarray,table,rowerror,rowstate,haserrors | 
convertto-json).replace('null', '"§n§"') | convertfrom-json | export-csv 
-path "$($tableName).csv" -usequotes asneeded


### import using psql
\copy whatever_tablename from whatever_tablename.csv (format csv, header 
on);

Kind Regards,

Holger


-- 
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012


Вложения

Re: MSSQL to PostgreSQL Migration

От
JP Pozzi
Дата:
Hello,

You can also look at Postgresql Foreign Data Wrapper (FDW) which can give access to
"foreign" tables even for MSSQL.
The transfer will be immediate as :
insert into postgres_table select * from mssql_table;

Regards

JP P

----- Mail original -----
De: "Holger Jakobs" <holger@jakobs.com>
À: pgsql-admin@lists.postgresql.org
Envoyé: Jeudi 12 Janvier 2023 18:37:08
Objet: Re: MSSQL to PostgreSQL Migration

Am 12.01.23 um 04:21 schrieb Gurudutt Dhareshwar:
> For data you can move it using the SQL tool itself or take a BCP Out
> and then insert using the psql -d option .


Actually, bcp.exe does not do a very good job. It cannot make a
difference between an empty string and a NULL value, for instance.

If you try to export in tab-separated format
(https://www.iana.org/assignments/media-types/text/tab-separated-values),
carriage returns, newlines, tab character will all mess up the output.
And contained backslashes are not doubled as necessary for PG's copy
statement.

In case your tables aren't too large, you can export via PowerShell
keeping the differences between NULL and empty string. The way via JSON
may be a bit slow and heavy on memory, though.


### Code for Powershell

install-module sqlserver

$SqlParams = @{
   ServerInstance = 'server_name'
   UserName = 'user_name'
   Password = 'very_secret'
   Database = 'db_name'
}

$tableName = 'whatever_tablename'
(invoke-sqlcmd @SqlParams -query "Select * from $tableName" |
select-object * -excludeproperty
itemarray,table,rowerror,rowstate,haserrors |
convertto-json).replace('null', '"§n§"') | convertfrom-json | export-csv
-path "$($tableName).csv" -usequotes asneeded


### import using psql
\copy whatever_tablename from whatever_tablename.csv (format csv, header
on);

Kind Regards,

Holger


--
Holger Jakobs, Bergisch Gladbach, Tel. +49-178-9759012