SQLServer2000:批量备份数据库
/* *功能:备份当前服务器上所有数据库,因为系统数据库和样例数据库也在sysdatabases表中, *它们的ID是前6个,所以加了dbid>6的条件,实际要根据服务顺上数据库的情况而定 *spaden 2011.4.1 */ use master declare @dbname varchar(200),@bakname varchar(1000),@path varchar(1000),@datestr varchar(50) set @datestr= CONVERT(varchar(12) , getdate(), 112 ) +'.bak' set @path='d:\' declare cs cursor for select name from sysdatabases where dbid>6 open cs FETCH NEXT FROM cs into @dbname WHILE @@FETCH_STATUS = 0 begin set @bakname=@path+@dbname+@datestr BACKUP DATABASE @dbname TO disk=@bakname FETCH NEXT FROM cs into @dbname end close cs deallocate cs