Board logo

标题: [文本处理] 批处理怎样每1048576行生成一个文件 并把每列数据都对齐? [打印本页]

作者: bandover    时间: 2019-1-22 08:54     标题: 批处理怎样每1048576行生成一个文件 并把每列数据都对齐?

之前写了一个 生成txt的命令if exist "D:\a.txt" (sqlcmd -S"127.0.0.1"  -U"sa" -P"123456" -d"**B" -Q"SELECT ROW_NUMBER () OVER (ORDER BY(SELECT 0)) AS rownum,t1.ID,t1.AtlasNo,t1.AtlasName,t2.AtlasIP,t2.VIN_Number,t2.Torque,t2.Angle,t2.Tightening_Status,t2.AddTime  from tb_AtlasInfo t1 inner join Log_AtlasLastTighteningResultData t2 on t1.IP=t2.AtlasIP where t1.AtlasNo like '%%'and t1.AtlasName like '%%' and t2.VIN_Number like '%%'and (isnull('2018-05-01 00:00:00','')=''or t2.AddTime>='2018-05-01 00:00:00') and (isnull('2018-05-31 23:59:59','')=''or t2.AddTime<='2018-05-31 23:59:59') and isnull(t2.VIN_Number,'')!=''" -o "d:\a.txt") else (sqlcmd -S"127.0.0.1"  -U"sa" -P"123456" -d"**B" -Q"SELECT top 10 ROW_NUMBER () OVER (ORDER BY(SELECT 0)) AS rownum,t1.ID,t1.AtlasNo,t1.AtlasName,t2.AtlasIP,t2.VIN_Number,t2.Torque,t2.Angle,t2.Tightening_Status,t2.AddTime  from tb_AtlasInfo t1 inner join Log_AtlasLastTighteningResultData t2 on t1.IP=t2.AtlasIP where t1.AtlasNo like '%%'and t1.AtlasName like '%%' and t2.VIN_Number like '%%'and (isnull('2018-05-01 00:00:00','')=''or t2.AddTime>='2018-05-01 00:00:00') and (isnull('2018-05-31 23:59:59','')=''or t2.AddTime<='2018-05-31 23:59:59') and isnull(t2.VIN_Number,'')!=''" -o "d:\a.txt")
这个生成后
就这个样子 请各位帮忙
作者: Batcher    时间: 2019-1-22 09:31

test.bat
  1. @echo off
  2. powershell -c "$FN=1; gc a.txt | %% {ac a-$FN.txt $_; $LN++; if ($LN -eq 1048576) {$FN++; $LN=0}}"
复制代码





欢迎光临 批处理之家 (http://www.bathome.net/) Powered by Discuz! 7.2