--SQL如何备份到异机
--写成存储过程,建立作业定时备份~~~
sp_configure 'show advanced options',1
reconfigure
go
sp_configure 'xp_cmdshell',1
reconfigure
go
--在sql中映射一下就可以了
exec master..xp_cmdshell 'net use z: \\192.168.1.18\D$ "123456" /user:192.168.1.18\User1'
/*--说明:
exec master..xp_cmdshell 'net use z: \\本地IP地址或机器名\c$ "密码" /user:本地IP地址或机器名\用户名'
z:是映射网络路径对应本机的盘符,与下面的备份对应
\\xz\c$是要映射的网络路径
xz\administrator
xz是远程的计算机名,
administrator是登陆的用户名
密码 面指定的administrator用户的密码
--*/
--备份;with init覆盖 |noinit添加
backup database KF_Exam_1 to disk='Z:\H_BACKUP.bak' with init
--COPY
--exec master..xp_cmdshell 'copy E:\H_BACKUP.bak z:'
--删除(这句可以去掉)
--exec master..xp_cmdshell 'del E:\H_BACKUP.bak'
--完成后删除映射
exec master..xp_cmdshell 'net use z: /delete'
go
--关闭shell
sp_configure 'xp_cmdshell',0
reconfigure
wzbjz.codeplex.com
go
sp_configure 'show advanced options',0
reconfigure
go