Originally posted by tomorrower at 2006-9-28 05:12:
这样也不对:
for /f "tokens=2,3* delims=|" %%i in (txip1.txt)
do ( echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >a.sql)
提示为:
...
一楼代码的问题的确出在那个重定向不在FOR语句执行范围内.
而这里改过的代码也不对, 建议for /?看看!
代码修改如下:
@echo off
for /f "tokens=2,3* delims=|" %%i in (txip1.txt) do (
echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >>a.sql
)
pause
发过贴才发现, 楼主的原意不是这样的>a.sql这一句为覆盖, 楼主可能是要追加>>a.sql
Last edited by pengfei on 2006-9-28 at 05:48 ]
Originally posted by tomorrower at 2006-9-28 05:12:
This is also incorrect:
for /f "tokens=2,3* delims=|" %%i in (txip1.txt)
do ( echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >a.sql)
The prompt is:
...
The problem with the code on the first floor is indeed that the redirection is not within the execution range of the FOR statement.
And the modified code here is also incorrect. It is recommended to look at for /?!
The code is modified as follows:
@echo off
for /f "tokens=2,3* delims=|" %%i in (txip1.txt) do (
echo 'update dzhd_t_txfjxx set v_ip=%%k where c_jgbh=%%i and c_txdm=%%j ;' >>a.sql
)
pause
Just found out after posting the thread that the original intention of the landlord is not that the sentence >a.sql is to overwrite. The landlord may want to append >>a.sql
Last edited by pengfei on 2006-9-28 at 05:48 ]