OSQL data formating problem

Posted on 2008-06-19
Medium Priority
Last Modified: 2012-06-27
OSQL - problem a line break is occuring in the output.

In certain records line breaks are introduced into the output while using osql
The data in the database is free from line breaks and carriage returns and all other non alphanumeric characters.

I've changed the "maximum characters per column" in query analyser to 8000 and tried increasing the dos window size to 1000. But that doesn't work.

If I use query analyser with results to file the data output is fine.

I'm using SQL server 2000

The OSQL is :-
osql -S ServerName -d DatabaseName -E -w1200 -Q DatabaseName.dbo.StoredProcedureName -o C:\OutFile.csv

The stored procedure (StoredProcedureName) queries various tables and uses a cursor with print to output the data as comma separated variables. This output is 910 characters long including the commas  
Question by:Pete_Burke
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 30

Assisted Solution

nmcdermaid earned 500 total points
ID: 21828746
What do you mean by:

>> If I use query analyser with results to file the data output is fine.

Is a DOS window the only point you are seeing a line break?? It is practical to only ever send it to a file and view the file?

Accepted Solution

Pete_Burke earned 0 total points
ID: 21828846
In query analyser right click on the query window and select the option "results to file" in that file the output is ok.

The OSQL is :-
osql -S ServerName -d DatabaseName -E -w1200 -Q DatabaseName.dbo.StoredProcedureName -o C:\OutFile.csv

in the file C:\OutFile.csv some records have line breaks.

Author Comment

ID: 22067840
points awarded

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What if you have to shut down the entire Citrix infrastructure for hardware maintenance, software upgrades or "the unknown"? I developed this plan for "the unknown" and hope that it helps you as well. This article explains how to properly shut down …
In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
This is a high-level webinar that covers the history of enterprise open source database use. It addresses both the advantages companies see in using open source database technologies, as well as the fears and reservations they might have. In this…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question