Hamo
Hamo

Reputation: 177

Convert a .bak file to .sql file

I have a asp script that I'm intending to write it with PHP so I have to get its database and use it.

I have the database as .bak file which I understood that it's a backup and I wanna change it to be .sql to import it in phpMyAdmin

I read about this matter in the web but I didn't find an accurate tutorial that goes through the whole process.

They are talking about mssql database but I didn't even reach this step..

Any help will be highly appreciated. Thanks in advance :)

Upvotes: 13

Views: 67522

Answers (2)

Hogan
Hogan

Reputation: 70523

Note, all of this applies to MS SQL because .bak is a usually a MS SQL backup.

A .bak can't be converted to SQL directly -- it contains a backup of a database which does not have a clear relationship to SQL.

You could restore the backup and then use SQL Server tools and then use that to make some SQL to recreate the SQL server objects but not the dat.

From SQL Server Management Studio: Datbases item, right click "Restore Database" then from datbase right click script database.

This won't script the data.


The other option is to use RedGate's excellent tools, which should do everything you want.

http://www.red-gate.com/products/sql-development/sql-toolbelt/

Upvotes: 10

user330315
user330315

Reputation:

Most probably the .bak file is indeed a binary backup of a Microsoft SQL Server database (which is something completely different than MySQL).

So you will first need to install Microsoft SQL Server (Express) together with the SQL Server Management studio (I think there is a bundled download "SQL Server Express including Tools".

In the Management Studio you can then import the .bak file into a new database. Once the import is finished you can use it to create SQL script out of the database.

Upvotes: 5

Related Questions