-- If I have a database in Simple recovery mode, it is possible to BACKUP a
FILEGROUP. However, it does not seem possible to RESTORE it.
-- Is it ever possible to RESTORE it? I personally didn't think it was
possible in Simple recovery mode, but then it doesn't make sense you can back
it up successfully.
IF EXISTS (SELECT * FROM master..sysdatabases WHERE name = N'test_db' )
DROP DATABASE test_db
GO
CREATE DATABASE test_db
ON PRIMARY
( NAME = test_db_file_1,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_1.mdf',
SIZE = 3MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%),
( NAME = test_db_file_2,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_2.ndf',
SIZE = 1MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%),
FILEGROUP test_db_group_1
( NAME = test_db_file_3,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_3.ndf',
SIZE = 1MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%),
( NAME = test_db_file_4,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_4.ndf',
SIZE = 1MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%),
FILEGROUP test_db_group_2
( NAME = test_db_file_5,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_5.ndf',
SIZE = 1MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%)
LOG ON
( NAME = test_db_log_file_1,
FILENAME = N'C:\program files\microsoft sql
server\MSSQL.2\MSSQL\Data\test_db_log_1.ldf',
SIZE = 1MB,
MAXSIZE = 200MB,
FILEGROWTH = 10%)
GO
-- Put it into simple recovery model
ALTER DATABASE test_db SET RECOVERY SIMPLE
GO
-- Backup single filegroup
BACKUP DATABASE test_db FILEGROUP = 'test_db_group_1' TO DISK =
'test_db_group_1 fg2.bak' WITH INIT
GO
BACKUP DATABASE test_db FILEGROUP = 'test_db_group_2' TO DISK =
'test_db_group_2 fg2.bak' WITH INIT
GO
-- Can I ever RESTORE it
RESTORE DATABASE test_db ???
GO
Andrew J. Kelly - 31 Jul 2008 18:57 GMT
I believe if the Filegroup is Read-only you can back it up and restore it.
But otherwise you need to be able to apply the logs after you restore a file
or filegroup to ensure consistency. I don't know why they don't throw an
error, maybe they should.

Signature
Andrew J. Kelly SQL MVP
Solid Quality Mentors
> -- If I have a database in Simple recovery mode, it is possible to BACKUP
> a
[quoted text clipped - 71 lines]
> RESTORE DATABASE test_db ???
> GO