1

I am running OSQL command in .bat file and I am running my SQL script and generating the output in a text file, however the data in the file is scattered and I want to generate the file in the same format as i can generate via SQL Server manually.

I have also tried with .rpt and .txt format but still facing the same issue.

So if anyone can suggest any command or any alternative way, so that I can generate the file same as I am generating manually through SQL server.

Any suggestions or idea is appreciated.

Thanks.

1 Answers1

0

You can use some options like -s "," to separate your columns by a comma. In my following example I am executing a store procedure from command line. e.g :

osql -E -Q "SET NOCOUNT ON;EXECUTE REPORTDB.[DBO].[SP_LOAD_USERDATA] %date%" -o C:\ADELPHE\OUTPUT_FOLDER\_%date%.txt -w 700 -s","

Have a look on this manual.

Robbert
  • 6,481
  • 5
  • 35
  • 61