方法:
(1)將數據備份在遠程的服務器中。
(2)遠程共享某個目錄
(3)將遠程數據備份文件拷貝到本地機中
(4)清除遠程共享的目錄
這裏主要用到的是sqlserver中內部的函
1.清除老的c:/temp2的文件,並新建c:/temp2'文件
cnn0.Execute "exec master..xp_cmdshell 'rd c:/temp2'"
cnn0.Execute "exec master..xp_cmdshell 'md c:/temp2'"
2.共享目錄:
cnn0.Execute "exec master..xp_cmdshell 'net share SQLDATABACK2=C:/temp2'"
3.備份文件
cnn0.Execute "backup database " & s_db_name & " to disk='c:/temp2/" & Date & ".dat'"
4.遠程複製到指定目錄
fso.copyfile "//" & serverName & "/SQLDATABACK2/" & Date & ".dat", Trim(Text1), True
5.清理文件。
cnn0.Execute "exec master..xp_cmdshell 'net share SQLDATABACK2 /delete'"
cnn0.Execute "exec master..xp_cmdshell 'rd c:/temp2 /s/Q'"