Reputation: 107
I am running a batch file by using the below command which basically pulls the data from a sql table.My result txt file is giving a blank line at the end.
SQLCMD.EXE -d FCRS_STG -i D:\export.sql -o E:\result.txt -s"," -W -h-1
export.sql was a simple select query as
SET NOCOUNT ON
SELECT * from dbo.VW_FDM_SALES_ADJUST where app ='CN'
Please help me to remove the blank line.
Thanks, Ravi.
Upvotes: 2
Views: 2684
Reputation: 37569
This removes the last line:
@echo off &setlocal
for /f "tokens=1*delims=:" %%i in ('findstr /n "^" result.txt') do set /a count=%%i
for /f "tokens=1*delims=:" %%i in ('findstr /n "^" result.txt') do if %%i lss %count% >>newfile.txt echo.%%j
endlocal
Upvotes: 1