Showing posts with label property. Show all posts
Showing posts with label property. Show all posts

Thursday, March 8, 2012

Database restore to new database

Hello all,

I am using SQLDMO to try and restore a database to a 'new' database. I am using the relocatefiles property and setting it correctly, but when I restore I always get the error:

"[Microsoft][ODBC SQL Server Driver][SQL Server]Logical file 'OLDDATABASENAME' is not part of database 'NEWDATABASENAME'. Use RESTORE FILELISTONLY to list the logical file names.
[Microsoft][ODBC SQL Server Driver][SQL Server]RESTORE DATABASE is terminating abnormally."

My code is set up like this:

restoreObject.RelocateFiles = "[oldDbName],[C:\newDbName.mdf],[oldDbName],[C:\newDbName.ldf]";

Any ideas? Can I assume the logical file is the same as the 'old' database name?

When I try and use the 'readfilelist' function to get the list of logical filenames, I always get empty results.

what are the logical filenames of your new database?

they must match the logical filenames from the backup.

hope this helps

|||

you can use readfilelist function to read the logic file name

for example: your "oldDbName" may be "oldDbName_data" and "oldDbName_log"

but i found the function is failure in SQL SERVER 2005 EXPRESS, i don't know why....

Sunday, February 19, 2012

database properties show incorrect information

The backup file size for database xyz shows the size of 200,000kb.

However when I click on the property from enterprise manager, it shows 3000MB. What is the reason that the backup file shows a much smaller size than the size that showed from EM db property?

Thanks for your input!

Database files have a "reserved" space which wil give you the availbility, as in your case to put data up to 3000MB to it, before it will grow (if set up). The backup file on the other side will only backup the data not the reserved space which might be not occupied. You will need to have a look in a procedure like sp_Spaceused or the proper view in Enterprise Manager to get the occupied values.

HTH, Jens Suessmeyer.

http://www.sqlserver2005.de