Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Line Size of an query result set

Author  Topic 

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2013-02-26 : 02:26:45
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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-02-26 : 02:30:34
select cast(10 as varchar(60)) as test

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

Go to Top of Page

mmkrishna1919
Yak Posting Veteran

95 Posts

Posted - 2013-02-26 : 02:41:40
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

52326 Posts

Posted - 2013-02-26 : 02:52:24
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
   

- Advertisement -