Solved

Copy command not working to create "txt" file from two "csv" files

Posted on 2013-10-24
3
438 Views
Last Modified: 2013-10-25
Working Code:

bcp "select * from livedb.dbo.tblRCASelfPay" queryout "P:\ACCOUNTING\RCA.csv" -T -SPTM-DR01 -w -t^,
bcp "select * from livedb.dbo.tblRCAHdr" queryout "P:\ACCOUNTING\RCAHdr.csv" -T -SPTM-DR01 -w -t^,
copy P:\ACCOUNTING\RCAHdr.csv + P:\ACCOUNTING\RCA.csv P:\Accounting\RCAData.txt


Non-Working Code:

bcp "select * from livedb.dbo.tblRCASelfPay" queryout "P:\RCA-Self Pay\SP_Data\RCA.csv" -T -SPTM-DR01 -w -t^,
bcp "select * from livedb.dbo.tblRCAHdr" queryout "P:\RCA-Self Pay\SP_Data\RCAHdr.csv" -T -SPTM-DR01 -w -t^,

copy P:\RCA-Self Pay\SP_Data\RCAHdr.csv + P:\RCA-Self Pay\SP_Data\RCA.csv P:\RCA-Self Pay\SP_Data\RCAData.txt


The above BCP statements and Copy command are being used to combine two SQL tables into a "txt" file.

For both BCP statements the creation of the "csv" files work in both paths.  However, the COPY command does not work for the second group of statements.  The only difference I see is the PATH.

I am hoping another set of eyes can see a problem with the second COPY command.

Thanks

Glen
0
Comment
Question by:GPSPOW
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
Giovanni Heward earned 500 total points
ID: 39599128
I'd place the paths in quotes, as there appears to be spaces.

copy "P:\RCA-Self Pay\SP_Data\RCAHdr.csv"+"P:\RCA-Self Pay\SP_Data\RCA.csv" "P:\RCA-Self Pay\SP_Data\RCAData.txt"

Open in new window

0
 

Author Closing Comment

by:GPSPOW
ID: 39599136
Thanks

That did it.

glen
0
 
LVL 14

Expert Comment

by:Giovanni Heward
ID: 39600731
Your welcome, here's a bonus:

setlocal enabledelayedexpansion
set p=P:\RCA-Self Pay\SP_Data
bcp "select * from livedb.dbo.tblRCASelfPay" queryout "!p!\RCA.csv" -T -SPTM-DR01 -w -t^,
bcp "select * from livedb.dbo.tblRCAHdr" queryout "!p!\RCAHdr.csv" -T -SPTM-DR01 -w -t^,

copy "!p!\RCAHdr.csv"+"!p!\RCA.csv" "!p!\RCAData.txt"

Open in new window

0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

This article covers how to install the Microsoft Windows Operating System (OS). What is covered in this article:  > Different Versions and Editions of the Windows OS  > Upgrading versus Fresh Installation of the OS           - Steps to take pr…
Citrix XenApp, Internet Explorer 11 set to Enterprise Mode and using central hosted sites.xml file.
In this video, we discuss why the need for additional vertical screen space has become more important in recent years, namely, due to the transition in the marketplace of 4x3 computer screens to 16x9 and 16x10 screens (so-called widescreen format). …
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now