Beispiel Code um aus mehreren Sätze eine „Kommaseparierte Liste“ zu haben:
IF EXISTS (select name from sysobjects where name = 'fod_implode' and Type = 'FN') Drop function fod_implode CREATE FUNCTION sysdba.fod_implode ( @id AS char(12)) RETURNS varchar(4000) BEGIN DECLARE @implode varchar(3000) Set @implode = '' DECLARE Name_Cursor CURSOR FOR SELECT lastname FROM sysdba.Contact WHERE accountid = @id DECLARE @Value varchar(255) OPEN Name_Cursor FETCH NEXT FROM Name_Cursor into @Value WHILE (@@FETCH_STATUS = 0) BEGIN if @implode = '' Set @implode = @Value else Set @implode = @implode + ', ' + @Value FETCH NEXT FROM Name_Cursor into @Value END CLOSE Name_Cursor DEALLOCATE Name_Cursor --Rueckgabewert: RETURN @implode END