June 23, 2006 at 3:10 am
Guys,
I have a query like:
Select EmployeeName from Employees where Boss = 3
And I get results back like this:
Tom
Dick
Harry
Moe
but I'd like to get back a sigle line result containing all the rows separed by commas like this:
Tom,Dick,Harry,Moe
Is there an easy way to accomplish this ?
Or do I have to pull the results into a table variable and cycle through them with a cursor to create a concatenated string?
Any help greatly appreciated...
June 23, 2006 at 3:20 am
Ooops,
Found the answer in a post down below there in the forums...
I'd just have to do:
DECLARE @MyString varchar(1000)
SET @MyString = ''
SELECT @MyString = @MyString + BaseCurrency + ', '
FROM OutputFileTypes
SELECT @MyString
Which works fine,
Thanks anyway.
June 23, 2006 at 4:01 am
you would also need to remove the trailing comma from the string if you use the above approach.
Tim Wilkinson
"If it doesn't work in practice, you're using the wrong theory"
- Immanuel Kant
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply