I have two pieces of code:- Sample ONE is working perfectly fine inside a stored procedure.
- Sample TWO returns all the records I want but
- Sample THREE is the one that's causing me trouble. It will only return one (the last) record.
What am I missing here? Thanks for helping!!-- Sample ONE: SELECT @ActiveUsers = @ActiveUsers + ', ' + CAST(e.Username AS varchar(30)) FROM TicketUsers tu INNER JOIN Employee e ON tu.UserID = e.ID WHERE tu.TicketID = @ParentID AND tu.DateClose IS NULL SET @ActiveUsers = SUBSTRING(@ActiveUsers, 3, 100) SELECT @ActiveUsers-- Sample TWO: SELECT e.* FROM dbo.fn_TaskOwners(@TaskID) t INNER JOIN Employee e ON t.ID = e.ID ORDER BY e.LastName-- Sample THREE: SELECT @String = @String + ', ' + CAST(e.FirstName + ' ' + e.LastName AS VARCHAR(100)) FROM dbo.fn_TaskOwners(@TaskID) t INNER JOIN Employee e ON t.ID = e.ID ORDER BY e.LastName SET @String = SUBSTRING(@String, 3, 100) SELECT @String
Gero**It's better to light a candle than to curse the darkness.**