Create function [dbo].[GetChildWorkerExtension]
(
@ChildId int
)
returns nvarchar(100)
as
begin
declare @ret nvarchar(2000)
set @ret = ''
select @ret = @ret+';'+(case Relationship
when 1 then '父亲'
when 2 then '母亲'
when 3 then '爷爷'
when 4 then '奶奶'
when 5 then '姥姥'
when 6 then '姥爷'
else '其它' end)+':'+ Phone from GuardianInfo where ChildId=@ChildId and (Phone is not null or Phone!='')
set @ret = case when len(@ret)>0 then stuff(@ret,1,1,'') else @ret end
return @ret
end