?
Solved

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

Posted on 2013-10-24
3
Medium Priority
?
445 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 15

Accepted Solution

by:
Giovanni Heward earned 2000 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
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…
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…

771 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