If it's always only two rows like that, you could use a self-join. How do you know the order of the rows, though? I.e., what's the primary key on the table? If, say, the table has another column named Sequence and a primary key of (UserID,Sequence), and there are always two rows per UserID, then an example of such a self-join is:
SELECT a.UserID, a.Value + ' ' + b.Value
FROM dbo.YourTable a INNER JOIN dbo.YourTable b ON a.UserID = b.UserID AND a.Sequence < b.Sequence;
If there may be more than just two per UserID, you can extend this idea up to seven or eight self-joins before it becomes sluggish, and you'd be faced with (slower) outer joins if the number of rows per ID isn't fixed:
SELECT a.UserID, a.Value + ISNULL(' ' + b.Value,'') + ISNULL(' ' + c.Value,'') + ISNULL(' ' + d.Value,'')
FROM dbo.YourTable a LEFT JOIN dbo.YourTable b ON a.UserID = b.UserID AND a.Sequence < b.Sequence
LEFT JOIN dbo YourTable c ON a.UserID = c.UserID AND b.Sequence < c.Sequence
LEFT JOIN dbo.YourTable d ON a.UserID = d.UserID AND c.Sequence < d.Sequence;
There are a couple of other ways to do this in SQL Server, one that works in any version since 6.5 is to use a UDF:
CREATE FUNCTION dbo.ConcatMyTableValues (@UserID int) RETURNS varchar(8000) AS
BEGIN
DECLARE @Values varchar(8000);
SELECT @Values = ISNULL(@Values,'') + ' ' + Value
FROM dbo.YourTable
WHERE UserID = @UserID
ORDER BY Sequence;
RETURN @Values;
END;
Then you can use this as an aggregate function:
SELECT UserID, dbo.ConcatMyTableValues(Value) AS Values
FROM dbo.YourTable
GROUP BY UserID;
You can also use SQL Server's XML capablitities if on SQL Server 2005 or later:
SELECT a.UserID, STUFF(
(SELECT b.Value + ' '
FROM dbo.YourTable b
WHERE a.UserID= b.UserID
ORDER BY b.Sequence
FOR XML PATH(''))
,1,1,'')
FROM dbo.YourTable a
GROUP BY a.UserID