Delete line null file created CMD

1

I have a batch which takes the name of the file and path of a parameter in a table and then executes a select and saves it in a txt. The problem that is occurring is that in the last line I create a record with NULL (I am going to attach an image) which makes the error that the system takes this file. Then I copy the batch REM - PROOF

  for /f  %%A in  ('sqlcmd -S Vane -d PEPE-U sa -P Vane -Q "set nocount on;select (SELECT Valor FROM ParametrosVarios WHERE Codigo = 1000)+NombreArchivo+replace(convert(varchar,(SELECT FechaProcesoAnterior FROM para),2),'.','')+'.txt' FROM Interfaz_NombresArchivos WHERE Id=3"') do set Nombre="%%A"
    SET result=%Nombre:/= % 
    echo %result% 
    sqlcmd -S Vane -d PEPE-U sa -P Vane -Q "set nocount on; delete from Interfaz_Prueba where fechaejecucion = convert(varchar(10),getdate(),120)"
    sqlcmd -S Vane -d PEPE -U sa -P Vane -Q "set nocount on; BEGIN exec sp_Interfaz_Prueba END"
    sqlcmd -S Vane -d PEPE -U sa -P Vane -Q "set nocount on; select CAST(entidad as varchar)+NroOperacion+cast(SucursalOperacion as varchar)+CAST(entidad as varchar)+cast(Producto as varchar)+cast(Subproducto as varchar)+Moneda+cast(SucursalOperacion as varchar)+replicate(' ',4)+cast(CanalDeVenta as varchar)+cast(OficialVenta as varchar)+cast(OficialComercial as varchar)+replicate(' ',4-datalength(OficialComercial))+cast(saldo as varchar)+cast(saldo as varchar)+fechaInicio+'9999-12-31'+EstadoDelContrato+FechaEstado+replicate(' ',2)+replicate(' ',2)+replicate(' ',8)+replicate(' ',20)+'0000BANKTRADE'+REPLICATE(' ',111)+TipoMovimiento from Interfaz_Prueba where fechaejecucion = convert(varchar(10),getdate(),120)"  -o %result% -W -w 1024 -s"" -h-1

    
asked by vanessa 24.11.2017 в 18:37
source

1 answer

0

Good morning

You can try using this other for at the end of your script to get what you want from the file

for /f "delims=loQueSea" %%i in (ficheroSinTratar.txt) do >> ficheroTratado.txt echo %%i

This for is going to take all the lines of the file called FileSimply.txt that do not start with loQueSea (after the delims) and will put them to a new file called fileTreatment.txt

Greetings and I hope you have served

    
answered by 01.02.2018 в 10:27