Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««12

how to restore .ndf file in database SQL 2005 Expand / Collapse
Author
Message
Posted Tuesday, April 29, 2014 5:14 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:52 AM
Points: 42,445, Visits: 35,501
You never need to create a dummy database before restoring. The restore process creates the database. Creating an empty database and then restoring over it is just a waste of time.

If the database which the backup was created from had an ndf file, then the backup would include that and the restore would recreate it. There's no silly tricks needed.

If your restore isn't creating the ndfs, then you may be looking at the wrong backup. RESTORE HEADERONLY and RESTORE FILELISTONLY to see what is inside the backup



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1565857
Posted Tuesday, April 29, 2014 8:13 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, April 29, 2014 8:13 AM
Points: 3, Visits: 5
Hi GilaMonster,

You may think that the way i resolved this issue is totally stupid but please hear me out

First of, i'm using " SQL Server Management Studio 2005 " to take backup and restore the database. I'm pretty sure that my backup has all the mdf,ldf, and ndf files. You told that i don't need to create a new db to restore the database in the target server. I tried, but no help.

Here is how i solved it.

As i told in the earlier reply, i tried to create a dummy .ndf file. I achieved it by opening new query in SQL Server Management Studio and saved it as filename.ndf ( the file name which was prompted while restoring ). This did the magic... restoration completed like a charm.

I'm pretty sure that this is NOT the right way to solve this issue. But this might help some one is resolving the issue.


Any way thanks for your help.
Post #1565944
Posted Tuesday, April 29, 2014 8:55 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 3:52 AM
Points: 42,445, Visits: 35,501
????

To restore a database, right click the databases folder (object explorer), select Restore database. Select the Device radio button. Locate the backup, select which backupset in the file you want to restore (if there's more than one), Type in a database name (the database name dropdown can be typed into). Go to the second tab, specify the new locations for files if applicable.
Click OK.

That's it, no creating dummy databases, no creating dummy files, they're not needed and doing so can lead to an incorrect perception as to what's happening and what's required.

Or, if you prefer,

RESTORE DATABASE <new database name> FROM  DISK = <location of backup>
WITH
MOVE <logical name of the mdf file> TO <new location and file name for the mdf>,
MOVE <logical name of an ndf file> TO <new location and file name for the ndf>,
.. repeat for other ndf files ...
MOVE <logical name of the log file> TO <new location for the log file>




Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1565986
Posted Friday, June 20, 2014 2:26 AM
Mr or Mrs. 500

Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500Mr or Mrs. 500

Group: General Forum Members
Last Login: Today @ 2:13 AM
Points: 557, Visits: 492
Hi subhash,

Get logical file names as follows

restore filelistonly from disk='your backup path\filename.bak'

then restore database as follows,

restore database database_name from disk='your backup path\filename.bak'
with
move 'Logical_name for mdf file' to 'Path where you want to create .mdf file',
move 'Logical_name for ndf file' to 'Path where you want to create .ndf file',
move 'Logical_name for ldf file' to 'Path where you want to create .ldf file',
stats=1


Note:- Depends on number of your .ndf file use move to part.
Post #1584237
Posted Saturday, June 21, 2014 8:59 AM


Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, July 1, 2014 6:39 AM
Points: 4, Visits: 45
One of my database has ndf file but its not there in the other one.No idea why this is happening.Is anything sruiously wrong with one of the database.

Post #1584603
« Prev Topic | Next Topic »

Add to briefcase ««12

Permissions Expand / Collapse