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)
 Query formatting

Author  Topic 

mail2chandus
Starting Member

1 Post

Posted - 2003-12-11 : 04:20:26
Hello all,

I have a problem with query formatting.

i have a table which Details which has fields

Name -varchar(20)
Roll - varchar(4)

When I say

Select * from Details

the result is


Name RollNO
--------------- ---------------------
Shekar 007
Ravi 008

and so on.

But I want the data to be displayed as follows

Shekar-007,ravi-008,ramu-009,...

and so on.
Can anyone help me in this regard


thanks
Shekar

mohdowais
Sheikh of Yak Knowledge

1456 Posts

Posted - 2003-12-11 : 04:33:37
Something like:

DECLARE @str varchar(1000)

SELECT @str = ISNULL(@str + ', ', '') + (Name + RollNo) FROM tableName

PRINT @str

Search the forums for CSV (comma separated values), you'll plenty of resources


Owais

We make a living out of what we get, but we make a life out of what we give.
Go to Top of Page
   

- Advertisement -