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
 Result in one Record

Author  Topic 

amodi
Yak Posting Veteran

83 Posts

Posted - 2009-06-21 : 04:06:35
Hello friends,
I have a SELECT statement, say: SELECT XYZ FROM TABLEA
the output is :
XYZ
A
B
C
D
My requirement is i want the result in one record as
ABCD

Thanks

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-21 : 04:10:39
[code]
declare @result varchar(8000)

select @result = ''

select @result = @result + XYZ FROM TABLEA ORDER BY XYZ

select @result
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

amodi
Yak Posting Veteran

83 Posts

Posted - 2009-06-21 : 04:45:27
Thanks Khtan!
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2009-06-21 : 04:47:16
you are welcome

some further reference for you to refer
Rowset string concatenation: Which method is best ?
concatenate records without UDF

KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2009-06-21 : 18:36:24
Heh... I love it. Why doesn't anyone ask the OP why they want to denormalize data in such a fashion anymore?

--Jeff Moden
"Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! "
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row"

For better, quicker answers, click on the following... [url]http://www.sqlservercentral.com/articles/Best+Practices/61537/[/url]
Go to Top of Page
   

- Advertisement -