I would like to modify this function to concatenate/return just the TOP 6 values. I have tried many things. Can anyone help? Thanks!
CREATE FUNCTION [dbo].[Rpt_ConcatSecondaryDxIds] (@VisitNumber varchar(20))RETURNS varchar(max)
AS
BEGIN
DECLARE @DxList varchar(max);
SELECT @DxList = COALESCE(@DxList + ', ', '') + DX_ID FROM DX where VISIT_NO =@VisitNumber and Dx_Type <> 0 and Dx_Type <> 1 ORDER BY DX_ID;
RETURN (@DxList);
END
GO
Linda