SQL Server backs up all database code

Source: Internet
Author: User

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

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.