Solved

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

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

ScreenConnect 6.0 Free Trial

Want empowering updates? You're in the right place! Discover new features in ScreenConnect 6.0, based on partner feedback, to keep you business operating smoothly and optimally (the way it should be). Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

This is a little timesaver I have been using for setting up Microsoft Small Business Server (SBS) in the simplest possible way. It may not be appropriate for every customer. However, when you get a situation where the person who owns the server is i…
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…
This video Micro Tutorial explains how to clone a hard drive using a commercial software product for Windows systems called Casper from Future Systems Solutions (FSS). Cloning makes an exact, complete copy of one hard disk drive (HDD) onto another d…
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…

777 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