我正在运行一个创建csv文件的批处理文件,以从数据库中获取数据

时间:2019-05-22 12:14:29

标签: batch-file

@echo Off
set qty=-1

:loop4weekends
set "separator1=-"
set "separator2=_"
echo >"%temp%\%~n0.vbs" s=DateAdd("d",%qty%,now)
echo>>"%temp%\%~n0.vbs" d=weekday(s)
echo>>"%temp%\%~n0.vbs" WScript.Echo year(s)^&_
echo>>"%temp%\%~n0.vbs"         right(100+month(s),2)^&_
echo>>"%temp%\%~n0.vbs"         right(100+day(s),2)^&_
echo>>"%temp%\%~n0.vbs"         d
for /f %%a in ('cscript //nologo "%temp%\%~n0.vbs"') do set result=%%a
del "%temp%\%~n0.vbs"
endlocal& set "YY=%result:~0,4%" & set "MM=%result:~4,2%" & set "DD=%result:~6,2%" & set "daynum=%result:~-1%"

set "weekend="
if %daynum% EQU 1 set weekend=1&set "qty=-3"
if %daynum% EQU 7 set weekend=1&set "qty=-2"
if defined weekend goto :loop4weekends
set "day=%YY%%separator1%%MM%%separator1%%DD%"
set "day1=%YY%%separator2%%MM%%separator2%%DD%"

sqlcmd  -E -S %MachineIP% -Q "exec T_StoreProcedure 
@companyFundIDs=N'',@inputDate=N'%RESULT1%' "  -d %ClientDB% -o "DAVIDCAPITAL_EOD_%rdate%.csv" -s"," -W

ECHO CSV file has been generated successfully
pause

0 个答案:

没有答案