November 15, 2007 at 1:45 pm
I have table - employeedescription which stores description of the employee. An employee can have multiple descriptions, below functions returns all the employeedescription for each employee, Is ther any way to concatenate all the descriptions for an employee into a single row
empidempdescription
_______________________________
1Joined in 1971
1Raise in 1976
1change department in 1980
output should be
empidempdescription
_______________________________
1Joined in 1971 Raise in 1976 change department in 1980
ALTER function [dbo].[F_GETDESC](@sk bigint) returns varchar(2000)
as
begin
declare @desc varchar(2000)
SELECT @desc= ltrim(rtrim(description))+ '...'
FROM employeedescription
WHERE employeedescription.key=@sk
return @desc
end
Any suggestions and input should help
Thanks
November 15, 2007 at 2:19 pm
AM -
Jeff Moden and I were just having a bit of a conversation about that in another thread. He just posted an example that will work on a SQL 2000 box (which would work for you). It's on the top of page 6. He also goes into detail about the RIGHT and the WRONG way to use such a solution (which can go horribly wrong if you don't pay attention...)
thread is here:
----------------------------------------------------------------------------------
Your lack of planning does not constitute an emergency on my part...unless you're my manager...or a director and above...or a really loud-spoken end-user..All right - what was my emergency again?
November 15, 2007 at 2:59 pm
Actually, you can get to the precise post Matt is talking about by clicking on the following... not need to hunt pages...
http://www.sqlservercentral.com/Forums/Topic419472-65-2.aspx#bm422799
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply