W
willing66
Unregistered / Unconfirmed
GUEST, unregistred user!
CREATE TABLE t_test10( FID INT, FDATA VARCHAR(50))SELECT * FROM t_test10INSERT INTO t_test10(FID, FDATA)VALUES(1, 'Q')INSERT INTO t_test10(FID, FDATA)VALUES(1, 'T')INSERT INTO t_test10(FID, FDATA)VALUES(2, 'U')INSERT INTO t_test10(FID, FDATA)VALUES(2, 'P')SELECT ALTER FUNCTION dbo.ufn_GetGroupString_t_test10(@AFid INT)RETURNS VARCHAR(256)AS BEGIN DECLARE @AStr VARCHAR(256); SELECT @AStr = ''; SELECT @AStr = @AStr + FDATA + ',' FROM t_test10 WHERE FID = @AFid; IF (LEN(@AStr) > 0) SELECT @AStr = SUBSTRING(@AStr, 1, LEN(@AStr) - 1); RETURN @AStr;END;SELECT DISTINCT FID, (SELECT dbo.ufn_GetGroupString_t_test10(FID)) AS STRAFROM t_test10