Solved

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

Posted on 2013-10-24
3
443 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 15

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 15

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever had a hard drive that you can't boot into, but need to change the registry? Here is the solution! This article guides you through accessing and editing a registry of a non-primary drive. To read registry information on a non-prim…
Entering time in Microsoft Access can be difficult. An input mask often bothers users more than helping them and won't catch all typing errors. This article shows how to create a textbox for 24-hour time input with full validation politely catching …
Windows 8 came with a dramatically different user interface known as Metro. Notably missing from that interface was a Start button and Start Menu. Microsoft responded to negative user feedback of the Metro interface, bringing back the Start button a…
With the advent of Windows 10, Microsoft is pushing a Get Windows 10 icon into the notification area (system tray) of qualifying computers. There are many reasons for wanting to remove this icon. This two-part Experts Exchange video Micro Tutorial s…

733 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