Tuesday, 1 January 2013

SQL Server Full Backup and Differential Backup with Restore Option


------SQL SERVER FULL BACKUP AND DIFFERENTIAL BACKUP WITH RESTORE OPTION--

--FIRST THING TAKE  A FULL BACKUP OF A DATABASE THERE IS DEMO IS MY DATABASE NAME--

 1) BACKUP DATABASE DEMO TO DISK  ='C:\DEMO_FULL.BAK' --RUN THIS F5

 2)--Insert some data into a table that belong to your database--

  INSERT asd VALUES('ASHISH','MOH',3,4,3333)
  INSERT asd VALUES('malwal','chd',32,42,33323)

  3)  -- Now take Differential Backup--

  BACKUP DATABASE DEMO TO DISK  ='C:\DEMO_DIFF.BAK'WITH DIFFERENTIAL
 
  ---------Now restore full backup and Differential Backup---

  4 --First restore full back its mandetory for restore any differential backup or any log backup --

 5  Delete asd

   SELECT * FROM dbo.asd

6----Now restore FullBackup WITH REPLACE Norecovery

 RESTORE DATABASE DEMO FROM DISK ='C:\DEMOFULL.BAK' WITH REPLACE , Norecovery

 --After finish this command refresh your database and you can see a up green arrow point on your database
  --it means  your database in restoring mode and you can restore differential backup or log backup

7)   RESTORE  DATABASE DEMO FROM DISK  ='C:\DEMO_DIFF.BAK'  WITH RECOVERY

    8) ---- Execute your table now--

    SELECT * FROM dbo.asd

No comments:

Post a Comment