数据库全部备份方法
今天需要重装系统,数据库太多,就找了一个全部备份数据库的sql方法,留在此做标记。
use master declare @DbName varchar(60) declare @BackSql varchar(1000) declare myCursor cursor for SELECT [name] FROM SYSDATABASES where [name] not in ('master','model','msdb','tempdb') order by [name] open myCursor fetch next from myCursor into @DbName while(@@FETCH_STATUS = 0) begin if datename(weekday, getdate())='星期三' --每周三覆盖上周三的 begin select @BackSql='Backup DATABASE ['+@DbName+'] to disk=''E:\DataBase\'+@DbName+'星期三.bak'' with format' end else--每天覆盖上一天的 begin select @BackSql='Backup DATABASE ['+@DbName+'] to disk=''E:\DataBase\'+@DbName+'AutoBack.bak'' with format' end exec(@BackSql) fetch next from myCursor into @DbName end close myCursor DEALLOCATE myCursor
==============================================================================
青春匆匆,很多人都有自己的座右铭,鞭策自己前进,当没看到座右铭的时候又忘了自己要干什么,就这样天天立志,志天天立,最终还是那个初出茅庐的小菜鸟。从现在开始,慢慢去改掉懒惰的习惯。慢慢去加强学习,直到慢慢成功。==============================================================================