Link to home
Start Free TrialLog in
Avatar of mgreif
mgreif

asked on

MS SQL Server OSQL - Column format/length

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.
Avatar of SimonLarsen
SimonLarsen

try

select cast (1 as int)

or

select ltrim(rtrim(1))
ASKER CERTIFIED SOLUTION
Avatar of muzzy2003
muzzy2003

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
Avatar of mgreif

ASKER

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!
Thanks for the revision.