- 工信部备案号 滇ICP备05000110号-1
- 滇公安备案 滇53010302000111
- 增值电信业务经营许可证 B1.B2-20181647、滇B1.B2-20190004
- 云南互联网协会理事单位
- 安全联盟认证网站身份V标记
- 域名注册服务机构许可:滇D3-20230001
- 代理域名注册服务机构:新网数码
SQL Server 批量完整备份 实现方式一:使用游标
执行下面的SQL脚本就可以备份当前数据库实例的所有数据库(除了系统数据库);
-- ============================================= -- Create date: <2015/12/03> -- Description: <批量备份数据库> -- ============================================= DECLARE @FileNameVARchar(200), @CurrentTimeVARchar(50), @DBNameVARchar(100), @SQL VARchar(1000) SET @CurrentTime = CONVERT(char(8),GETDATE(),112) + CAST(DATEPART(hh, GETDATE()) AS VARCHAR) + CAST(DATEPART(mi, GETDATE()) AS VARCHAR) DECLARE CurDBName CURSOR FOR select NAME from Master..SysDatabases where dbid>4 OPEN CurDBName FETCH NEXT FROM CurDBName INTO @DBName WHILE @@FETCH_STATUS = 0 BEGIN --Execute Backup SET @FileName = 'E:DBBackup' + @DBName + '_' + @CurrentTime SET @SQL = 'BACKUP DATABASE ['+ @DBName +'] TO DISK = ''' + @FileName + '.bak' + ''' WITH NOINIT, NOUNLOAD, NAME = N''' + @DBName + '_backup'', NOSKIP, STATS = 10, NOFORMAT' EXEC(@SQL) --Get Next DataBase FETCH NEXT FROM CurDBName INTO @DBName END CLOSE CurDBName DEALLOCATE CurDBName
执行完上面的SQL脚本,会在E:DBBackup的目录下生成似下图的备份文件:
售前咨询
售后咨询
备案咨询
二维码
TOP