标题: [已解决]10元求合并下列代码 [打印本页]
作者: brothersonline 时间: 2017-7-18 22:46 标题: [已解决]10元求合并下列代码
请高手将此批处理及SQL、VBS文件合并成一个VBS文件(有偿),在windows 2008 server (64位)下执行
目的:在win2008 server下静默执行此VBS文件,将sql数据库备份
SQL:- DECLARE @name varchar(45)
- DECLARE @datetime char(17)
- DECLARE @path varchar(255)
- DECLARE @bakfile varchar(290)
- set @name='GXSV4'
- set @datetime=CONVERT(char(11),getdate(),120) + REPLACE(CONVERT(char(8),getdate(),108),':','')
- set @path='D:\SQLBACKUP'
- set @bakfile=@path+'/'+@name+'_'+@datetime+'.BAK'
- backup database @name to disk=@bakfile with name=@name
- go
复制代码
批处理:- @echo off
- set path=%path%;C:\Program Files\Microsoft SQL Server\100\Tools\Binn
- set dates=%date% %time%
- echo %dates% >> D:\SQLBACKUP\logs.txt
- echo Sql_Back_Start >> D:\SQLBACKUP\logs.txt
- echo . >> D:\SQLBACKUP\logs.txt
- SQLCMD.exe -S 127.0.0.1 -U sa -P Abc123 -i mybackup.sql
- set dates=%date% %time%
- echo %dates% >> D:\SQLBACKUP\logs.txt
- echo Sql_Back_Finish >> D:\SQLBACKUP\logs.txt
- echo . >> D:\SQLBACKUP\logs.txt
- echo . >> D:\SQLBACKUP\logs.txt
- ::pause
复制代码
VBS文件:- Dim WSHShell
- Set WSHShell = WScript.CreateObject("WScript.Shell")
- WSHShell.run "cmd /c AutoBackup.BAT",vbhide
- Set WSHShell = Nothing
- WScript.Quit(0)
复制代码
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |