Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Export to CSV Without Output Before Last Step 1

Status
Not open for further replies.

cghoga

Programmer
Jun 26, 2003
614
US
Greetings,

I have a SQL 2000 (I also have 2005) qry file that runs through several steps. The qry file initially creates a table with a key column and several empty columns and then runs through a series of inserts. At the very end I execute a qry that rolls it all up into the view I need.

I recently created a batch file that executes this qry file on the scheduler overnight and emails me the resulting CSV file.

Problem is when the CSV file is created/output all of the SQL feedback above the final qry script (which i am only interested in seeing in the CSV) appears.

For example...

(20918 rows affected)

(13090 rows affected)

(93732 rows affected)

(46879 rows affected)

(16905 rows affected)
FieldA FieldB FieldC FieldD FieldE FieldF
-- -- -- -- -- --
xxx xxx xxx xxx xxx xxx
xxx xxx xxx xxx xxx xxx
xxx xxx xxx xxx xxx xxx
xxx xxx xxx xxx xxx xxx
xxx xxx xxx xxx xxx xxx

I can do some data scrubbing/manipulation to the CSV file to arrive at a cleaner format, but this may not be scalable as I might need to develop a process for each report I create. If I had to would be open to doing this, but I wanted to run this by you all to see if there is an efficent way to only export the result for the last qry in my sql file or if there is a process you have implemented to handle this type of thing.

I do not have SQL storage space as an option. The process creates temp tables on the fly, loads data to the temp tables, exports to the CSV, and leaves no foot print.

Sorry if I have confused.

Thanks for your time and help,

CGH
 
You need to add SET NOCOUNT ON before running your commands.
 
Thanks Markros, any ideas on how to get the columns to autofit in the CSV? :) I won't press my luck. Thanks again for your help!

cgh
 
I think you can set up AutoFit if you open this file in Excel. You may then try to re-save it as CSV, though I don't know if it would be autofit then.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top