来个gawk的。- @echo off
- setlocal EnableDelayedExpansion
- set txt=insert.sql
- gawk "BEGIN{FS=\"\\(^|\\)^| \\(^|\\) ^|, ^| \";}{count=(NF-5)/2;printf(\"DELETE FROM %%s WHERE\",$3);for(i=1;i<=count;i++){if($(i+count+4)==\"NULL\")continue;if(i==count){printf(\" %%s=%%s;\n\",$(i+3),$(i+count+4));}else{printf(\" %%s=%%s AND\",$(i+3),$(i+count+4));}}}" !txt!
- pause
复制代码
|