Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I have a database with 3 filegroups: PRIMARY, AP, and GL.

I did a full database backup. I did a partial restore of just the PRIMARY and AP files successfully using this command:

-- Partial Backup (Primary & AP) to same database (works)
RESTORE DATABASE TestPartial
    FILE = N'TestPartial',
    FILE = N'TestPartialAP'
    FROM DISK = N'J:\SQL\MSSQL10_50.SGA\MSSQL\Backup\TestPartial.bak'
    WITH
        FILE = 1, NOUNLOAD, REPLACE, PARTIAL, STATS = 10

Is it possible to do this same partial restore, but to a different database? I have a database called TestPartial1, which I am trying to partially restore into. However, I'm getting the following error:

The backup set holds a backup of a database other than the existing 'TestPartial1' database.

Here is my code:

-- Partial Backup (Primary & AP) to a different database (doesn't work)
RESTORE DATABASE TestPartial1
    FILE = N'TestPartial',
    FILE = N'TestPartialAP'
    FROM DISK = N'J:\SQL\MSSQL10_50.SGA\MSSQL\Backup\TestPartial.bak'
    WITH
        FILE = 1, NOUNLOAD, REPLACE, PARTIAL, STATS = 10,
        MOVE N'TestPartial' TO N'J:\SQL\MSSQL10_50.SGA\MSSQL\DATA\TestPartial1.mdf',
        MOVE N'TestPartial_log' TO N'J:\SQL\MSSQL10_50.SGA\MSSQL\DATA\TestPartial1_log.ldf',
        MOVE N'TestPartialAP' TO N'J:\SQL\MSSQL10_50.SGA\MSSQL\DATA\TestPartial1AP.ndf'
share|improve this question
1  
It will require a full restore to a different database. –  Shawn Melton Dec 22 '11 at 18:52

1 Answer 1

up vote 2 down vote accepted

Is it possible to do this same partial restore, but to a different database?

Short answer I'm afraid, no.

Best bet is to do a partial restore to a new database then copy the tables and data to your target with:

share|improve this answer
    
That's what I'm trying to do: a partial restore to a new database. That's what I can't get to work. –  Jeff Stock Dec 22 '11 at 19:05
    
Your question reads (to me anyway) that your trying to restore DatabaseA to an existing DatabaseB, rather than a new DatabaseB. Is this not the case? –  Mark Storey-Smith Dec 22 '11 at 19:16
    
No, DatabaseB is a new database, meaning that I already created just to restore into. –  Jeff Stock Dec 22 '11 at 19:32
1  
You are missing the point. You created DatabaseB, so it exists, it is an existing database, you are not restoring to a new database. Run your script without creating the database first. –  Mark Storey-Smith Dec 22 '11 at 19:41
    
Wow, that works if the database doesn't exist. Thanks –  Jeff Stock Dec 22 '11 at 20:30

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.