Friday, March 9, 2012

Format the column with

Hello,
Can you tell me how can i format the column with in the output of a query?
The results must be returned as text and my output is like this:
y x
-- --
1 2
the way im treating the output is to cast the field as varchar(xxx):
select cast(y as varchar(1)), cast(x as varchar(1))
from xxxxxx
y x
- -
1 2
It is possible to do it with a different way?
Thanks and best regards.Hi
SELECT coalesce(x,'')+coalesce(y,'') as blabla
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:5386EC39-E9F2-4D5E-A965-E9BFF9984D3E@.microsoft.com...
> Hello,
> Can you tell me how can i format the column with in the output of a query?
> The results must be returned as text and my output is like this:
> y x
> -- --
> 1 2
> the way im treating the output is to cast the field as varchar(xxx):
> select cast(y as varchar(1)), cast(x as varchar(1))
> from xxxxxx
> y x
> - -
> 1 2
> It is possible to do it with a different way?
> Thanks and best regards.|||SQL Server returns meta-data with the result set. This meta-data includes in
formation about the
datatype for each columns. A tool like Query Analyzer uses this meta-data to
define the length of
the columns presented. Note that when you execute into grid, things are diff
erent. The columns are
indeed made smaller to include more information in what you see. So, in othe
r words, what you see if
done by the client application, not SQL server itself.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
news:5386EC39-E9F2-4D5E-A965-E9BFF9984D3E@.microsoft.com...
> Hello,
> Can you tell me how can i format the column with in the output of a query?
> The results must be returned as text and my output is like this:
> y x
> -- --
> 1 2
> the way im treating the output is to cast the field as varchar(xxx):
> select cast(y as varchar(1)), cast(x as varchar(1))
> from xxxxxx
> y x
> - -
> 1 2
> It is possible to do it with a different way?
> Thanks and best regards.|||Thanks Uri,
Best regards
"Uri Dimant" wrote:

> Hi
> SELECT coalesce(x,'')+coalesce(y,'') as blabla
>
> "CC&JM" <CCJM@.discussions.microsoft.com> wrote in message
> news:5386EC39-E9F2-4D5E-A965-E9BFF9984D3E@.microsoft.com...
>
>

No comments:

Post a Comment