Create a new Database from .bak file OR Restore a database from .bak file with out using database file (.mdf,log_ldf) Path..
-
Saturday, April 09, 2011 10:11 AM
i need to create a database, and i have a mydatabase.bak( another database from other system).
nw i need to create a database and restore the database from that .bak file. is it possible to create and restore with in single query?
[ my requirement is restore a database from .bak file without using database file path]
Please help me
- Edited by Sathya From Madurai Saturday, April 09, 2011 10:13 AM sql server 2008 r2 and c#
All Replies
-
Saturday, April 09, 2011 10:19 AM
RESTORE DATABASE myNewDb FROM DISK = 'C:\tmp\mybak.bak'
will work, but you need to have the same directory structure as on original server.
With kind regards
Krystian Zieja
http://www.projectnenvision.com
Follow me on twitter
My Blog -
Saturday, April 09, 2011 10:30 AM
There is no problem to create a query to do the create and restore.
However, if you don't want to using the database file path, then No. You have to move your database file and log file in your backup database to your new created database data file and log file.
-
Saturday, April 09, 2011 12:09 PM
Why cant the restore be done in GUI itself in SSMS?
Regards and good Wishes, Deepak. -
Saturday, April 09, 2011 12:14 PMModerator
Hi Sathya,
Welcome to MSDN forums.
http://www.youtube.com/watch?v=BHevcPDAU7Q
Balmukund Lakhani | Please mark solved if I've answered your question, vote for it as helpful to help other user's find a solution quicker
--------------------------------------------------------------------------------
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------------------------------------------------------------------
My Blog: http://blogs.msdn.com/blakhani
Team Blog: http://blogs.msdn.com/sqlserverfaq -
Saturday, April 09, 2011 12:59 PM
thanks for your reply.
But my requirement is, i have one database(test) in my system. now i will take a backup this database(test.bak) manually. nw i will run my setup file(this is my c# project) to another one system, first it will be create a instance and then create a database, nw i need to restore this new database from my test.bak file(i included this backup file with my setup).
Here my problem is i don't know that new database file .mdf,log_mdf files path. So i need to restore this database from my backup file via SQL-DMO or SQLSMO concept.
i dont knw about this concepts clearly, but i think it will be only possible to restore directly.
Please help me, its very urgent for me.
-
Saturday, April 09, 2011 1:01 PMPlease explain me sir
-
Monday, April 11, 2011 2:21 AMModerator
Hi Sathya From Madurai,
SQL-DMO (SQL Server Distributed Management Objects) is a collection of objects which lets you program applications to manage and administer SQL Server. SQL-DMO has been superseded by SMO (SQL Server Management Objects) which is more powerful and extensive. Avoid using SQL-DMO because it will be removed in the future version. Here are threads about restoring database using SMO and DMO, please take a look.
As to the database files path, you can get them by the properties of the database.
Best Regards,
Stephanie Lv
- Marked As Answer by WeiLin QiaoModerator Tuesday, April 19, 2011 1:20 AM
-
Tuesday, April 12, 2011 4:48 AMyea i did sir with SMO. Thank you very much

