DECLARE @name AS VARCHAR(50) DECLARE @FileName AS VARCHAR(50) DECLARE @filedate AS VARCHAR(50)
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 = 'E:\dhaval\' + @name + '_' + @filedate + '.Bak' BACKUP DATABASE @name TO DISK = @FileName END
|