Here is an example for SQL Server: CREATE FUNCTION ConcatenateMyTableValues (@ID int) RETURNS varchar(max) AS BEGIN declare @s as varchar(max); select @s = isnull(@s + ',', '') + MyColumn from MyTable where ID = @ID; return @s end And then you could use it like this: select t. ID, t. Name, dbo.
ConcatenateMyTableValues(t. ID) from SomeTable t.
– David Brunelle Aug 20 '10 at 20:53 @David: Yes, it will return all of the MyColumn values concatenated together into a comma-delimited string. If you provide your query and schema, I can give you more precise code. – RedFilter Aug 20 '10 at 20:54 Sweet, I did find another way, but this is still a good answer.
:) – David Brunelle Aug 20 '10 at 20:55 @David: I recommend you use my approach over the cursor method, as it is slow enough already without adding the overhead of cursors into the mix. – RedFilter Aug 20 '10 at 20:59.
You can use COALESCE to convert values in one column to csv sqlteam.com/article/using-coalesce-to-bu... I am not sure how you will be able to create a function unless you do not mind creating a dynamic sql which can accept a column name and then build sql accordingly at run time. Edit. This works for SQL Server only.
Didn't realize that you have not mentioned any db.
DECLARE @list AS varchar(MAX) SELECT @list = ISNULL(@list + ',', '') + be FROM MyTable SELECT @list AS Result Here a way to do this recursive (ms sql).
Depends on your technology. If it is Oracle, check out the stragg function. sqlsnippets.com/en/topic-11591.html If it is MSSQL use the XML PATH trick sqlblogcasts.com/blogs/tonyrogerson/arch....
1 mysql has group_concat(column) – Hendrik Brummermann Aug 20 '10 at 20:39 Ooooh Nice I didn't know that :D – Biff MaGriff Aug 20 '10 at 20:51.
I guess I'm going to answer my own question since I actually got a way to do it using CURSOR (that keyword I was missing in my thoughs..) ALTER FUNCTION dbo. GET_NOM_MEDECIN_REVISEURS (@NoAs810 int) RETURNS NVARCHAR(1000) AS BEGIN IF @NoAs810 = 0 RETURN '' ELSE BEGIN DECLARE @NomsReviseurs NVARCHAR(1000) DECLARE @IdReviseurs AS TABLE(IdReviseur int) DECLARE @TempNomReviseur NVARCHAR(50) SET @NomsReviseurs = '' DECLARE CurReviseur CURSOR FOR SELECT DISTINCT Nom FROM T_Ref_Reviseur R INNER JOIN T_Signature S ON R. IdReviseur = S.
IdReviseur WHERE NoAs810 = @NoAs810 OPEN CurReviseur FETCH FROM CurReviseur INTO @TempNomReviseur WHILE @@FETCH_STATUS = 0 BEGIN SET @NomsReviseurs = @NomsReviseurs + @TempNomReviseur FETCH NEXT FROM CurReviseur INTO @TempNomReviseur IF @@FETCH_STATUS = 0 SET @NomsReviseurs = @NomsReviseurs + ' - ' END CLOSE CurReviseur RETURN @NomsReviseurs END RETURN '' END.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.