Jane Dallaway

Jane Dallaway

Jane Dallaway  //  Data loving developer/leader/product shaper, storyline curator/creator, life-long learner, photographer, dog owner, reader, crafter, gardener and occasional snowboarder

This blog contains all sorts of odds and ends, from event reviews, stuff about my storyline project, bits of craft, through thoughts on learning, to photography stuff, and general inspiration things. It's a bit all over the place with no real theme, but then so am I!

Email: jane @ dallaway.com
Also at:    

SQL Server 2005 restore error message

This is definitely a note to self, as I'm sure to have this happen again. I received the following error message this morning when attempting to restore a database

Msg 3219, Level 16, State 3, Line 2
The file or filegroup "MyDB_log" cannot be selected for this operation.

using script similar to the following

RESTORE database [MyDB]
FILE = N'MyDB' ,
FILE = N'MyDB_log' ,
FROM disk = N'C:\MyDB_backup.bak'
WITH FILE = 1,
MOVE N'MyDB' TO N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\MyDB.mdf',
MOVE N'MyDB_log' TO N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\MyDB.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO

To fix this, I simply removed the lines starting with FILE and ran it again. Success! So the final, working script was

RESTORE database [MyDB]
FILE = N'MyDB' ,
FILE = N'MyDB_log' ,
FROM disk = N'C:\MyDB_backup.bak'
WITH FILE = 1,
MOVE N'MyDB' TO N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\MyDB.mdf',
MOVE N'MyDB_log' TO N'c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\MyDB.ldf',
NOUNLOAD, REPLACE, STATS = 10
GO

0 comments

Leave a comment...