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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Ms SQL query view the out put in horizontal format

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2005-01-17 : 10:02:21
Abrahim writes "Hi all,

On MS SQL server 2000 I have the following SQL query that I like to view the out put in horizontal format:



Select Id, Fisrt_name, Last_name from ABC



Instead of getting out-put like



Id Fisrt_name Last_name

1 Jim Smith

2 Tom Jones



I like to see the out-put like:



Id 1 2

First_name Jim TOM

Last_name Smith Jones



Please advice.



Thanks in advance,"

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-01-18 : 00:51:06
[code]
Declare @s nvarchar(1000)
Select @s=coalesce(@s+' '+convert(varchar(12),id),convert(varchar(12),id)) from Table
Select @s
set @s=null
Select @s=coalesce(@s+' '+convert(varchar(12),First_Name),convert(varchar(12),First_Name)) from Table
Select @s
set @s=null
Select @s=coalesce(@s+' '+convert(varchar(12),Last_Name),convert(varchar(12),Last_Name)) from Table
Select @s
[/code]
Madhivanan
Go to Top of Page
   

- Advertisement -