Results 1 to 3 of 3
  1. #1
    Join Date
    Feb 2004

    Unanswered: Using OSQL for Query Output (csv formatted)

    I'm running a query with osql, and I'm trying to get some clean output that is comma delimited. So far my line looks like this:

    osql -E -n -d mydb -i custom.qry -o "c:\output\results.csv" -h-1 -s ","

    This works off a table with only two columns. I'm still left with a lot of extra spaces between the first column output and second column output, and at the bottom the text "(50 rows affected)".

    So instead of this:

    data1a (lots of spaces here) ,data1b
    data2a (lots of spaces here) ,data2b
    data3a (lots of spaces here) ,data3b
    (50 rows affected)

    I want to see this:


    Thanks very much for any help.

  2. #2
    Join Date
    Jan 2003
    Provided Answers: 17
    I can think of two things to remove the rowcount.

    1) Add "set nocount on" to your custom.qry.
    2) Use BCP. You will have to see if you can make your custom.qry into a view in the database. If it is a single select statement that should not be hard.

  3. #3
    Join Date
    Feb 2004
    Yea, I ended up using SET NOCOUNT ON, and also specificed the width to 500 so the output didn't newline several times. Instead of comma delimited I parsed it as though it was space delimited which works for what I needed it to do.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts