Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Stored Procedure to Backup all Databases Expand / Collapse
Author
Message
Posted Tuesday, September 25, 2007 2:38 PM


SSChasing Mays

SSChasing Mays

Group: Moderators
Last Login: Wednesday, July 23, 2014 1:21 PM
Points: 609, Visits: 407
Comments posted to this topic are about the item Stored Procedure to Backup all Databases

http://www.sqlserverio.com
http://www.cactuss.org
http://www.salssa.org
Post #402749
Posted Thursday, June 18, 2009 11:50 PM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Yesterday @ 2:43 PM
Points: 286, Visits: 255
I am also having a small script to backup all my databases.....






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

SET @path = 'd:\Backup\'
SELECT @fileDate = CONVERT(VARCHAR(20),GETDATE(),112)
SELECT name,flag=0 into #tempbackup FROM master.dbo.sysdatabases WHERE name NOT IN ('master','model','msdb','tempdb')
set rowcount 1
WHILE (exists(SELECT * FROM #tempbackup WHERE flag=0))
BEGIN
Select @name=name from #tempbackup WHERE flag=0
SET @fileName = @path + @name + '_' + @fileDate + '.BAK'
print @fileName
BACKUP DATABASE @name TO DISK = @fileName
Update #tempbackup set flag=1 WHERE flag=0 and name=@name
END
set rowcount 0
drop table #tempbackup




- Manish
Post #738064
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse