December 8, 2003 at 9:02 am
In SQL2000, how can I redirect the output of a query to a file with the data being ; delimited?
December 8, 2003 at 9:14 am
Something like...
Exec ('master.dbo.xp_cmdshell ''BCP ' + db_name(db_id()) + '..' + @TBName + ' OUT "' + @OutPutFile + '" -c -S"' + @@Servername + '" -a32768 -T -t"' + @Delimiter + '"''')
Also look at QUERYOUT keyword
Once you understand the BITs, all the pieces come together
December 8, 2003 at 9:34 am
Thankd you.
December 9, 2003 at 6:25 am
Use DTS. Set up an output file and use either a table or SQL statment to create the output. If you set it up dynamically you can change the source and/or the output filename so that the DTS can be reused.
Matt,
Peace Out!
Regards,
Matt
December 9, 2003 at 8:57 am
Another option...
Look at isql and osql.
"Keep Your Stick On the Ice" ..Red Green
December 9, 2003 at 10:07 am
DTS export to text and specify delimiter as ;.
-Isaiah
December 9, 2003 at 1:13 pm
I am having the same problem and will appreciate any ideas.
I notice that the BCP works only for a query or SP that conatins a single select statement. That is, it returns only one result set and will ignore the rest.
The DTS will do the same as it insists on a transformation being specified for the columns.
The osql is a good one excepts that you have to clean the file of headers or blank lines if you suppress headers. The real problem I have with osql is that it insists on giving out the columns as fixed width. This means columns are padded with spaces and distorts the output.
Thanks.
December 9, 2003 at 2:12 pm
Hi Eletuw,
Copy data to temp table before do BCP.
December 10, 2003 at 1:52 am
My select statements have different number of columns. Copying the data to a temp table is likely to be a pain.
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply