首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > SQL Server >

SqlServer2005外地备份

2012-09-29 
SqlServer2005异地备份EXEC sp_configure show advanced options, 1RECONFIGUREEXEC sp_configure xp

SqlServer2005异地备份
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 1;RECONFIGURE;--打开xp_cmdshell
exec master..xp_cmdshell --使用xp_cmdshell
'net use z: \\192.168.2.68\DB "电脑密码" /user:192.168.2.68\administrator' --net连接 ,asd为共享的文件夹,必须可修改。“” 是密码,administrator用户名
declare @a char(80)
select @a ='z:\sp_yzq_' + replace(replace(convert(varchar(19),getDate(),120),' ','-'),':','-') + '.bak' --根据时间定义文件备份名称
backup database sp_yzq to disk= @a   --JJ_sp 为需要备份的数据库
exec master..xp_cmdshell 'net use z: /delete' --删除net连接
EXEC sp_configure 'show advanced options', 1;RECONFIGURE;EXEC sp_configure 'xp_cmdshell', 0;RECONFIGURE;--关闭xp_cmdshell .只是将上面的后面的那个"1"改成"0"就可以了

热点排行