OSQL output file formatted so its readable

  • I have created a batch file that extracts SQL data into a text file. My question is their a way to alter the OSQL string so that its in a readable/usable format

    osql /Usa -P /dDATABASE /Q "SELECT * FROM table WHERE DATE BETWEEN '%DATE1%' AND '%DATE2%'" -oc:\test.txt -w80 -h-1 -u

    This codes produces data weirdly formatted.

  • This was removed by the editor as SPAM

  • What's weird? Do you have long strings in there?

    I don't think that osql will produce an easily readable format. It's designed to retrieve the data, but not for something like reporting. More for input to some other program. If you need some type of easy to read report, perhaps you want to look at Reporting Services. I think that can export to text.

  • Interesting. It works perfectly when placing it into a pre-existing Excel document:

    osql /Usa /P /dDATABASE /S /Q "Insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0', 'Excel 8.0;Database=C:\test.xls;HDR=YES', 'SELECT * FROM [sheet1$]')Select * from SUPPLYLIST where DATE BETWEEN '%DATE1%' AND '%DATE2%'"

    I suppose Notepad or Wordpad cannot be dictated to...Thanks anywho

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply