where to find MyDataBase.BAK file on SQL server 2008? - sql-server-2008

where to find MyDataBase.BAK file on SQL server 2008 ?
and how i can restore this file to my DataBase ?
thank's in advance

Did you back it up using SQL only without specifing a full path, e.g.
BACKUP DATABASE MyDataBase TO DISK='MyDataBase.BAK'
GO
I think by default your backup will get placed in the Backup folder in the SQL Server install, i.e. C:\Program Files\Microsoft SQL Server\MSSQL10.MSSQLSERVER\MSSQL\Backup or similar. You can restore it using
RESTORE DATABASE MyDataBase FROM DISK='MyDataBase.BAK'
GO
but if the orginal files are still there you'll need to specify alternate paths for the restore, e.g.
RESTORE DATABASE MyDataBaseTestRestore FROM DISK='MyDataBase.BAK'
WITH MOVE 'MyDataBase' TO 'C:\Temp\TestRestore.mdf',
MOVE 'MyDataBase_Log' TO 'C:\Temp\TestRestore_log.ldf'
GO
but it's so much simpler if you use management studio for all of this stuff.

Related

How to restore the database.bak file in SQL Server 2008

I have a database backup file I need to restore in SQL Server 2008.
I get an error
Specified cast is not valid. (SqlManagerUI)
Try this first and see if the backup is healthy:
DO
RESTORE FILELISTONLY FROM DISK = N'YOURFILE.bak'
then we can take it from there
Please check the Sql server version of the database from where you have backed up the version of database must be same or upper .Only then you can restore the database backup

How to transfer local sql server or database to another computer

I'm working on a project with 4 other guys, and we are developing an android app with a DB. Now, we are going to use a localhost for our SQL Server, I want to be able to take the database from my laptop and copy it to the other guys' computers. I"m using SQL Server 2008 Management Studio.
Any ideas of how to do it? I don't mind to copy the entire localhost server if we can do that.
BTW, I tried to backup the DB on my laptop by right-click on the DB (created .bak file) but there is no restore option on the other computer.
Thanks
Backup your data base and restore in the other machines
edit
If you dont find the restrore option, please try using sql script
ex:
RESTORE DATABASE nwind_new FROM DISK = 'c:\backups\northwind\nwind.bak'
WITH
MOVE 'northwind' TO 'd:\Program Files\Microsoft SQL
Server\Data\nwind_new.mdf'
MOVE 'northwind_log' TO 'd:\Program Files\Microsoft SQL
Server\Data\nwind_new_log.ldf'
You can try
See these links about backup and restore:
http://technet.microsoft.com/en-us/library/cc966495.aspx
and
http://blogs.msdn.com/b/sreekarm/archive/2009/09/11/move-a-database-from-one-server-to-another-server-in-sql-server-2008.aspx
To restore your database see this useful link:
http://msdn.microsoft.com/en-us/library/ms177429(v=sql.100).aspx
its weird you dont see the restore option. You could try deattaching the DB from its location, copy the files (DB and LOG) to the new location and attach it there.
MSDN

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 :)
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/
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.

Import .bak to MySQL (.sql)

I want to import a MS SQL SERVER2008 R2 database backup to MySQL Server. Any help on how I can convert the .bak to a .sql so that it can be imported to a MySQL database server?
I have read other threads regarding this but none have worked so far.
Thank you.
You can restore the database to a local version of SQL Server (you can download the free evaluation edition to do this):
http://msdn.microsoft.com/en-us/evalcenter/ff459612.aspx
Then you can use the import/export wizard in Management Studio to transfer your tables and other objects to your MySQL database (you may need additional ODBC drivers installed locally in order for SQL Server to establish a connection to MySQL).
EDIT
When restoring the database to SQL Server, don't use the clunky UI. Use an actual RESTORE DATABASE command. For example:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak';
Now, you may find that the original database was created with files placed on drives or folders that don't exist locally. So I suggest creating a very simple folder, temporarily, called c:\db_temp\, giving the Everyone account modify privileges, and then running the following:
RESTORE FILELISTONLY FROM DISK = 'c:\path\foo.bak';
This will return a resultset like:
LogicalName PhysicalName
----------- ------------
Foo C:\...\foo.mdf
Foo_log C:\...\foo_log.ldf
You need to build a RESTORE DATABASE command something like the following, based on the result above:
RESTORE DATABASE foo FROM DISK = 'c:\path\foo.bak'
WITH MOVE 'Foo' TO 'c:\db_temp\foo.mdf',
MOVE 'Foo_log' TO 'c:\db_temp\foo_log.ldf';

Restore SQL database from disc copy backup

I have managed to drop an SQL express 2008 database, that I accessed using SQL Management studio.
I don't have a backup of the database created through Management Studio or SQL, but I do have a disc copy of my entire c: drive made prior to a machine rebuild 4 weeks ago (A previous installation of the dropped database did exist at this stage). The disc backup contains all the databases (2) and versions, that I require.
Can I restore the databases from copies of raw files form a backup disc? If so is this complicated?
Which files would I need to be copy and to where?
Thanks in advance. Your help is appreciated.
Should be pretty easy:
(if needed) re-install SQL Server (Express) - you should make sure to install the version with the Management Studio
Copy the "raw" files (*.mdf and *.ldf) to the default data directory
In SQL Server Management Studio (Express), in the Object Explorer, go to the Database node and right-click and pick Attach...
Find your *.mdf file in question and select it
That should be all there is!
If you have the old .mdf and .ldf files you can use the "attach database" option rather than restore.