Solved

OSQL data formating problem

Posted on 2008-06-19
3
931 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
[X]
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
3 Comments
 
LVL 30

Assisted Solution

by:nmcdermaid
nmcdermaid earned 125 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?
0
 

Accepted Solution

by:
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.
0
 

Author Comment

by:Pete_Burke
ID: 22067840
points awarded
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
This post contains step-by-step instructions for setting up alerting in Percona Monitoring and Management (PMM) using Grafana.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.

724 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