August 28, 2008 at 6:35 am
DECLARE @T TABLE
(
X CHAR(3)
)
INSERT INTO @T SELECT 'AAA'
INSERT INTO @T SELECT 'BBB'
INSERT INTO @T SELECT 'CCC'
I need to return one row concatenation of entire rows in X field like 'AAA','BBB','CCC'
Is there any way to archive this without using cursors.
- Zahran -
August 28, 2008 at 6:45 am
HI There,
TRy and look up the Use of CTE's, this should point you in the right direction.
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
August 28, 2008 at 6:48 am
TRy and look up the Use of CTE's, this should point you in the right direction.
Can I use CTE in SQL Server 2000?
- Zahran -
August 28, 2008 at 6:50 am
Sorry my bad.
Forgot to see which version of SQL you using.
CTE's are not allowed in 2000 🙁
----------------------------------------------
Try to learn something about everything and everything about something. - Thomas Henry Huxley
:w00t:
Posting Best Practices[/url]
Numbers / Tally Tables[/url]
August 28, 2008 at 6:53 am
Hey try this one.
Declare @No varchar(100)
Set @No =''
select @No = @No + case when @No = '' then '' else ',' end + X
from @T
Select @No
karthik
August 28, 2008 at 6:53 am
hi Zahran,
please try this
DECLARE @Concat as varchar(8000)
SELECT @Concat = isnull(@Concat + ', ', '') + ltrim(rtrim(x))
FROM @T
-- result
SELECT @Concat as Result
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply