create Function [dbo].[GetJoinChar](@cghth varchar(50))
Returns varchar(5000)
As
Begin
Declare @s_sgdh varchar(5000)
Set @s_sgdh = ''
Select @s_sgdh = @s_sgdh + [拼接字段] + ','
from 表1 qd,表2 zy
where qd.cghtzyid=zy.cghtzyid and zy.关联字段= @cghth
Set @s_sgdh = Left(@s_sgdh, len(@s_sgdh) -1 )
Return(@s_sgdh)
End