SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Line Size of an query result set
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

mmkrishna1919
Yak Posting Veteran

India
95 Posts

Posted - 02/26/2013 :  02:26:45  Show Profile  Reply with Quote
Hi All,

when i execute a query in ms sql server the result set is showing in the below format

Sample query:
select 10 as test

Output:

test
---------------------------------------------------------------------
10

Actually i am saving the result set directly into the file,But the problem here is my result set is fixed length it has lecgth of 60 characters data is coming exactly 6o characters length,but the lines(----------- ) are coming with length of 5000.
So i am getting more than one row in the output file i need to avoid that i have to show only one line.

is there any option to set the line size..

Expected format

test
----------- (Need to reduce the size of line)
10

Thanks..

M.MURALI kRISHNA

Edited by - mmkrishna1919 on 02/26/2013 02:27:33

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/26/2013 :  02:30:34  Show Profile  Reply with Quote
select cast(10 as varchar(60)) as test

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

mmkrishna1919
Yak Posting Veteran

India
95 Posts

Posted - 02/26/2013 :  02:41:40  Show Profile  Reply with Quote
Thanks visakh,

in case of simple select i got it..

but my final select is as shown below

select cast(col1 as char(8))+
cast(col2 as char(12))+
cast(col3 as char(36))+'TEST'
from table_name

i am concatenating few columns and static data to make length of 60 characters.
In this case how can i use cast to control the number of lines in the result set

Thanks...


M.MURALI kRISHNA
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52325 Posts

Posted - 02/26/2013 :  02:52:24  Show Profile  Reply with Quote
same as before

select cast(cast(col1 as char(8))+
cast(col2 as char(12))+
cast(col3 as char(36))+'TEST' as char(60)) AS yourcolumnname
from table_name


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000