SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to restore .ndf file in database SQL 2005


how to restore .ndf file in database SQL 2005

Author
Message
GilaMonster
GilaMonster
SSC Guru
SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)

Group: General Forum Members
Points: 235008 Visits: 46376
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, MVP, M.Sc (Comp Sci)
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


subhash.ct32
subhash.ct32
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 Visits: 20
Hi GilaMonster,

You may think that the way i resolved this issue is totally stupid Cool 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... Hehe 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.
GilaMonster
GilaMonster
SSC Guru
SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)SSC Guru (235K reputation)

Group: General Forum Members
Points: 235008 Visits: 46376
????

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, MVP, M.Sc (Comp Sci)
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


Sushant Yadav
Sushant Yadav
Ten Centuries
Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)Ten Centuries (1.2K reputation)

Group: General Forum Members
Points: 1179 Visits: 871
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.
sqldbpro
sqldbpro
SSC Rookie
SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)SSC Rookie (30 reputation)

Group: General Forum Members
Points: 30 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.

:-)
subhash.ct32
subhash.ct32
SSC Rookie
SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)SSC Rookie (41 reputation)

Group: General Forum Members
Points: 41 Visits: 20
let us say my database in source server is cake_test and the database in the target server is also named as cake_test.

Now the backup of the database from the source server has the following files:

OriginalFile Name   Restore As

cake_test     cake_test.mdf
cream_data     cake_test.ndf
creamlayer_data     cake_test.ndf
cream_dat    cake_test.ndf
cake_test_log    cake_test.ldf
cream_log     cake_test.ldf

As instructed by you I have done the following:

RESTORE DATABASE cake_test
FROM DISK='D:\cake_test.bak'
WITH
MOVE 'cake_test' TO 'D:\MSSQL\DATA\cake_test.mdf'
,MOVE 'cream_data' TO 'D:\MSSQL\DATA\cake_test.ndf'
,MOVE 'creamlayer_data' TO 'D:\MSSQL\DATA\cake_test.ndf'
,MOVE 'cream_dat' TO 'D:\MSSQL\DATA\cake_test.ndf'
,MOVE 'cake_test_log' TO 'D:\MSSQL\DATA\cake_test.ldf'
,MOVE 'cream_log' TO 'D:\MSSQL\DATA\cake_test.ldf'

,stats=1

but no luck. I got the following error " RESTORE cannot process database 'cake_test' because it is in use by this session. It is recommended that the master database be used when performing this operation. "

Am i doing anything wrong here??

Please suggest.
addisionphilip
addisionphilip
Valued Member
Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)Valued Member (73 reputation)

Group: General Forum Members
Points: 73 Visits: 69
If built-in DBCC CHECKDB/repair tools fail to repair and restore the corrupt or damaged SQL server databases, it is good to opt for a third party application like this: http://www.serversdatarecovery.com/sqldatabase.html

This third party tool has been developed with strong scanning technology to analyze the database deeply and repair the corrupted items.
P Jones
P Jones
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2952 Visits: 1526
Try putting
USE Master
Go

before your "restore database" statement - you've probably got management studio pointing at the database you're trying to restore - it's a common slip up.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search