Showing posts with label backup. Show all posts
Showing posts with label backup. Show all posts

13 August 2014

When was the last successful backup in sqlserver?

Just right click on the Database and click on properties on the sql management studio.

http://adidotnettotal.blogspot.in/2014/08/when-was-last-successful-backup-in.html


On top of window the last full backup completion time and log backup completion time is shown.This is the simplest way of finding the success of a daily backup without even typing a command.

20 June 2014

Take backup all database from sql server using cursors



DECLARE @name VARCHAR(50) -- database name 
DECLARE @path VARCHAR(256) -- path for backup files 
DECLARE @fileName VARCHAR(256) -- filename for backup 
DECLARE @fileDate VARCHAR(20) -- used for file name

SET @path = 'C:\Backup\' 

SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)

DECLARE db_cursor CURSOR FOR 
SELECT name
FROM MASTER.dbo.sysdatabases
WHERE name NOT IN ('master','model','msdb','tempdb') 

OPEN db_cursor  
FETCH NEXT FROM db_cursor INTO @name  

WHILE @@FETCH_STATUS = 0  
BEGIN  
       SET @fileName = @path + @name + '_' + @fileDate + '.BAK' 
       BACKUP DATABASE @name TO DISK = @fileName 

       FETCH NEXT FROM db_cursor INTO @name  
END  

CLOSE db_cursor  
DEALLOCATE db_cursor