[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

MS SQL Server OSQL - Column format/length

Posted on 2004-11-21
6
Medium Priority
?
412 Views
Last Modified: 2008-02-01
MS SQL Server OSQL - I am running a query using osql and returning the resultant output to a file.  

It appears the minimum length of each column returned is 4 characters.  eg Try " SELECT '1' " as the query and it returns 4 characters, ie "1   ".  

Is there any way to to get rid of this apparent 4 character minimum per column?  I am  using the arguments -s -n -h-1 -m-1 -w 145 -b when running the query.
0
Comment
Question by:mgreif
  • 3
5 Comments
 
LVL 8

Expert Comment

by:SimonLarsen
ID: 12642001
try

select cast (1 as int)

or

select ltrim(rtrim(1))
0
 
LVL 16

Accepted Solution

by:
muzzy2003 earned 1000 total points
ID: 12643023
No there isn't. Sorry for the blunt answer.
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 12643198
If you want more control over the output format, then consider using DTS rather than osql. You can still run this from the command line using the DTSRUN utility.
0
 

Author Comment

by:mgreif
ID: 12649638
Thanks, I was sure that was the case since I couldn't find anything on it, but since I am fairly new to MS SqlServer, I wanted to find out!
0
 
LVL 16

Expert Comment

by:muzzy2003
ID: 12652007
Thanks for the revision.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
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…
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
Suggested Courses

872 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