Ion Freeman
3/7/2007 9:21:00 PM
So, say I have a situation like
create table #mable(mid INT, token nvarchar(16))
INSERT INTO #mable(0, 'foo')
INSERT INTO #mable(0, 'goo')
INSERT INTO #mable(1, 'hoo')
INSERT INTO #mable(1, 'moo')
And I want a resultset like
0 foo, goo
1 hoo, moo
I know I can get foo, goo, hoo, moo with
DECLARE @oowords nvarchar(31)
SELECT @oowords = ISNULL(@oowords + ', ', space(1)) + token FROM
#mable ORDER BY token
but it's not clear to me how I'd break it up by mid without a cursor.
Any ideas? I'm going to putter forward with the cursor, but I'd love
to be able to drop it.