Groups | Blog | Home
all groups > sql server programming > september 2003 >

sql server programming : Partial Database Backup


Suganthi
9/28/2003 11:35:32 PM
All
Is there any way of taking only few tables in Database?

I have tried with Filegroups...but its failing ...

If i use DTS can i restore properly when i need? Will it
maintains any Log information automatically?

If anyone having script for Filegroup backup please send
it to me..

thanks in advance

Regards
Uri Dimant
9/29/2003 10:05:14 AM
Look at this example
CREATE DATABASE mywind
GO

ALTER DATABASE mywind ADD FILEGROUP new_customers
ALTER DATABASE mywind ADD FILEGROUP sales
GO

ALTER DATABASE mywind ADD FILE
(NAME='mywind_data_1',
FILENAME='d:\mw.dat1')
TO FILEGROUP new_customers
ALTER DATABASE mywind
ADD FILE
(NAME='mywind_data_2',
FILENAME='d:\mw.dat2')
TO FILEGROUP sales

BACKUP DATABASE mywind
TO DISK ='d:\mywind.dmp'
WITH INIT
GO

USE mywind
GO

CREATE TABLE t1 (id int) ON new_customers
CREATE TABLE t2 (id int) ON sales
GO

BACKUP LOG mywind TO DISK='d:\mywind.dmp'
WITH NOINIT


RESTORE FILELISTONLY FROM DISK='d:\mywind.dmp'
GO
RESTORE HEADERONLY FROM DISK='d:\mywind.dmp'
GO


RESTORE DATABASE mywind_part
FILEGROUP = 'sales'
FROM DISK='d:\mywind.dmp'
WITH FILE=1,NORECOVERY,PARTIAL,
MOVE 'mywind' TO 'd:\mw2.pri',
MOVE 'mywind_log' TO 'd:\mw2.log',
MOVE 'mywind_data_2' TO 'd:\mw2.dat2'
GO

RESTORE LOG mywind_part
FROM DISK = 'g:\mywind.dmp'
WITH FILE = 2,RECOVERY
GO

Notice that t2 is accessible after the partial restore operation.
SELECT COUNT(*) FROM mywind_part..t2

Here is the result:

---------------
0

Notice that t1 is not accessible after the partial restore operation.

SELECT COUNT(*) FROM mywind_part..t1

Here is the resulting message:

The query processor is unable to produce a plan because
the table 'mywind_part..t1' is marked OFFLINE.






[quoted text, click to view]

AddThis Social Bookmark Button