Solved

OSQL data formating problem

Posted on 2008-06-19
3
922 Views
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  
0
Comment
Question by:Pete_Burke
  • 2
3 Comments
 
LVL 30

Assisted Solution

by:nmcdermaid
nmcdermaid earned 125 total points
Comment Utility
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?
0
 

Accepted Solution

by:
Pete_Burke earned 0 total points
Comment Utility
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.
0
 

Author Comment

by:Pete_Burke
Comment Utility
points awarded
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

763 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now