I need to import a SQL Server database which is in the
.mdf format into a PostgreSQL database. My system is Mac OS X.
How to do it in the easiest way?
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It only takes a minute to sign up.Sign up to join this community
I've had to do the opposite of this by which I used this process: https://dba.stackexchange.com/a/15833/4490
So you could reverse the insert ...
Link the postgres server
INSERT INTO OPENQUERY([ServerName],'select << column list >> from << table name >>') select << column list >> from << table name >>
as the query to use in the cursor.
This would require that you have already set up the database schema on the postgres server.
Later, in other answers, the user discovered Kettle with which you can build an ETL process to connect from MSSQL to postgres. I've never had success with the Import/Export wizard in SSMS, but if you can get that to work then that'd definitely be the lowest LOE.
Another option might be to install the
odbc_fdw (foreign data wrapper) http://www.postgresonline.com/journal/archives/249-ODBC-Foreign-Data-wrapper-to-query-SQL-Server-on-Window---Part-2.html
As @AaronBertrand noted, it is unclear as to whether or not you have a SQL Server instance available to you, or if it is just a data file that you have in your possession.