0

I have a table in PostgreSQL cpad.mst_Patient PatientID|FirstName|LastName|Gender|Dob|ClinicNumber|Facility|EntryPoint|RegistrationDate|Status|DeleteFlag

I have a similar table in MSSQL that i am doing data migration to. PostgreSQL is live database and i wanted to migrate the new registration from PostgreSQL to MSSQL using script. I am using MSSQL Cursor currently but its tedious because i have to transfer the database from PostgreSQL to Excel then import to MSSQL using integrated services which is time wasting. I need a code that can query data from PostgreSQL and paste it directly into MSSQL.

I am using PostgreSQL 9 and MSSQL 2016

1

1 Answer 1

0

You have a couple of options:

first, you can use a programming language like PHP or python that simply selects * from the postgres table and inserts into the mssql.

Second, you could use a postgres "FDW" (Foreign data wrapper) to set up a database connection from the postgres db to the mysql db using ODBC. Once you get that set up, the FDW makes postgress just see the mysql table as if it were in the postgres db. Then, it's as simple as

insert into mssqltab select * from postgrestab;

Setting up the FDW connection isn't something I'll cover here as most of the config will be determined by how your db and tables are configured.

Of course the third option is not to migrate to mssql because postgresql is a better db, but that's just my opinion.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.