问题背景:
从sp.log依次中读取一条记录,然后去连接数据库,但是每次连接可能要花费20S的时间,考虑到可能会有上百次操作,因而需要有个进度提示信息。。
下面是我写的代码,帮忙看看哪里有问题???
/*读取sp.log中总共有多少行记录*/- set /a m=1
- for /F "usebackq skip=2 tokens=1,2,3" %%i in ("%log%\sp.log") do (
- set /a m += 1
- )
-
- set count=1
- for /F "usebackq skip=2" %%i in ("%log%\sp.log") do (
- echo Backing up Store Procedure %%i >> "%log%\backup_all_sp_%db%_%srvname%_%year%%mon%%day%_%hour%%min%%ss%.log"
- sqlcmd -S%srvname% -d%db% -U%user% -P%password% -Q "select text from syscomments where id=object_id(%%i)" -o "%bak%\%srvname%_%db%_%%i_%year%%mon%%day%_%hour%%min%%ss%.PRC"
- echo ... Finished: %count%/%m% ...
- set /a count += 1
- )
复制代码 问题:
显示出来的不是预想中的结果
--------------------------------------
显示效果
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20
... Finished: 1 / 20 |