Today let me back up all the databases on the Internet, jerked a look, hundreds of, the pit dad, had to find on the internet is not easy, did not think that there is really a note down, after use, haha ...
Use masterdeclare @DbName varchar DECLARE @BackSql varchar (+) DECLARE mycursor cursor forselect [name] from Sysdatab Aseswhere [name] not in (' Master ', ' model ', ' msdb ', ' tempdb ') order by [Name]open Mycursorfetch next from MyCursor into @DbNam Ewhile (@ @FETCH_STATUS = 0) beginif datename (Weekday, GETDATE ()) = ' Wednesday '--Wednesday beginselect per Wednesday @BackSql = ' Backup DATABASE ' [' [Email protected]+ '] to disk= ' E:\DbBackUp\ ' [e-mail protected]+ ' Wednesday. Bak ' with format ' endelse--covers the day of Beginselect per day Backsql= ' Backup DATABASE [' [email protected]+ '] to disk= ' E:\database\alldatabase\ ' [email protected]+ ' 2013-06-05.bak ' With Format ' endexec (@BackSql) fetch next from MyCursor to @DbNameendclose mycursordeallocate mycursor
SQL Server backs up all database code