Nov 8, 2020

Data from MDF to SQL Script

I needed to export my data out of a MDF SQLServer file so that I could import it into a PostgreSQL database. In case we figure out time travel, or in a few years I need to remember how to get data out of a mdf, a series of images.

In server explorer, right clicking a connected mdf and selecting Browse in SQL Server Object Explorer provides a way to export a table's schema.
In the SQL Server Object Explorer, Right click on the MDF's table->view data, followed by the second script icon "Script to File" gives the SQL server format insert statements. I still had to convert from that into PostgreSQL, but that wasn't too hard once the data was in my hands.

No comments: