Create, backup and Restore Filegroup
Create database
[BANK_DATABASE_2]
ALTER DATABASE [Bank_DATABASE] ADD FILEGROUP [ACCOUNTS_FILEGROUP]
ALTER DATABASE
[Bank_DATABASE] ADD FILEGROUP [INSURANCE_FILEGROUP]
CREATE TABLE
tblACCOUNTS (AccID int, AccStatus bit, AccBal float) on [ACCOUNTS_FILEGROUP]
INSERT INTO
tblAccounts VALUES (10001, 797009, 1), (10002, 343733, 1),(10003, 0, 1)
INSERT INTO
tblAccounts VALUES (10002, 797010, 2), (10003, 343734, 2),(10004, 1, 2)
backup database
[Bank_DATABASE] to disk ='D:\LearningBackupClass\Bank_DATABASE_MonDiffbackup.bak' with differential
INSERT INTO
tblInsurance VALUES (10001, 457444, 1), (10002, 347333, 1),(10003, 440, 1)
INSERT INTO
tblInsurance VALUES (10002, 457445, 2), (10003, 347334, 2),(10004, 441, 2)
backup log
[Bank_DATABASE] to disk='D:\LearningBackupClass\Bank_DATABASE_Wedtrnbackup.trn' with format
RESTORE DATABASE
[BANK_DATABASE_2]
FILEGROUP = 'PRIMARY' FROM DISK = 'D:\LearningBackupClass\BANK_DATABASE_03AUG2023.BAK' WITH NORECOVERY, PARTIAL
RESTORE DATABASE
[BANK_DATABASE_2] FROM DISK = 'D:\LearningBackupClass\Bank_DATABASE_MonDiffbackup.bak' WITH NORECOVERY
RESTORE LOG
[BANK_DATABASE_2] FROM DISK = 'D:\LearningBackupClass\Bank_DATABASE_Wedtrnbackup.trn' WITH RECOVERY
RESTORE DATABASE
BANKDATABASE
FILEGROUP = 'PRIMARY' FROM DISK = 'D:\LearningBackupClass\BANK_DATABASE_03AUG2023.BAK' WITH NORECOVERY, PARTIAL
RESTORE DATABASE
BANKDATABASE
FILEGROUP = 'ACCOUNTS_FILEGROUP' FROM DISK = 'D:\LearningBackupClass\BANK_DATABASE_03AUG2023.BAK' WITH NORECOVERY
RESTORE DATABASE
BANKDATABASE FROM DISK = 'D:\LearningBackupClass\Bank_DATABASE_MonDiffbackup.bak' WITH NORECOVERY
RESTORE LOG BANKDATABASE FROM DISK = 'D:\LearningBackupClass\Bank_DATABASE_Wedtrnbackup.trn' WITH RECOVERY
0 Comments