Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple records in One Row Column Wise

Status
Not open for further replies.

adasoft

Programmer
Jan 31, 2002
132
IN
Hi, I am having 3 record in table with column name say col1, col2, col3.

I want to fetch all the 3 record in such a way that i can get the value of col3 for each record in one row.
Say Col3 , col3 , col3 .

Can any one help me I have to write these value in sequence in file.
 
what you are looking for crosstab query, have a look in the faqs

"I'm living so far beyond my income that we may almost be said to be living apart
 
Hi,

I have got the solution.One can get the help from this too

DECLARE @TestCol varchar(100)

SELECT @TestCol = COALESCE(@TestCol + ', ', '') +
CAST(Col3 AS varchar(5))
FROM TestTable
WHERE Col1 = 1

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top