sql server 类oracle vm_contact() 函数创建
2015-10-26 14:54 hf_sun 阅读(525) 评论(0) 编辑 收藏 举报CREATE FUNCTION dbo.fun_orgname(@id int)
RETURNS varchar(8000)
AS
BEGIN
DECLARE @str varchar(8000)
SET @str = ''
select @str = @str + ',' +r.NAME from PRINCIPAL_ORG t left join ORG r on t.ORG_ID=r.ID where t.PRINCIPAL_ID=@id
RETURN STUFF(@str, 1, 1, '')
END
GO