We help IT Professionals succeed at work.
Get Started

How to eliminate null record at end of ANSI file

GPSPOW asked
Last Modified: 2014-05-29
I am creating an ANSI formatted, PIPE delimited file using a batch file with BCP commands.  At the end of my files is a null record.  The vendor I am supplying these files to wants the NULL record eliminated.  Here is an example of data output and the Batch file coding.

Can someone tell me if there is a BCP switch that will do what I need?

P|A00000226880|FB|-4268.74|05/16/2014|05/16/2014|02/27/2014|03/17/2014|PTXHRS.65|PMT TEXAS HEALTH SPRING|MCR HMO|TXHRS.65|60372.04| | |I INP|MED
P|A00000105879|BD|-25.00|05/16/2014|05/16/2014|04/14/2011|04/18/2011|PFCA|FCA STATEMENT PAYMENTS|SP|SP|23766.94| | |I INP|MED

net use P: \\pmcfs\groups

bcp "select * from livedb.dbo.tbl_RCA_DAILY_TXN_HEADERS" queryout "\\pmcfs\groups\ACCOUNTING\RCA_DAILY_TXN_HEADERS.csv" -T -SPTM-DR01 -c -t^|

bcp "select * from livedb.dbo.tbl_RCA_DAILY_TXN_DETAIL" queryout "\\pmcfs\groups\ACCOUNTING\RCA_DAILY_TXN_Temp.csv" -T -SPTM-DR01 -c -t^|

copy \\pmcfs\groups\ACCOUNTING\RCA_DAILY_TXN_HEADERS.csv + \\pmcfs\groups\ACCOUNTING\RCA_DAILY_TXN_Temp.csv  "\\pmcfs\groups\ACCOUNTING\CHI\DailyTxnData\rca_p1_mt_daily_txn_"%date:~10,4%%date:~4,2%%date:~7,2%".csv"

net use P: /DELETE

Open in new window


Watch Question
Social distance; Wear a mask; Get vaccinated
Top Expert 2014
This problem has been solved!
Unlock 1 Answer and 29 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE