-- получаем список наименований владельцев
if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetUsersList]') and xtype in (N'FN', N'IF', N'TF'))
drop function [dbo].[GetUsersList]
GO
create function GetUsersList(@ObjectID integer)
returns nvarchar(4000)
as
begin
  declare @res nvarchar(4000)
  declare @sourceid integer
  select @sourceid = dbo.GetUsersSource(@ObjectID)
  set @res = ''
  select @res = @res +   
    case IsIndividual
      when 1 then Individuals.Name
      else Организация.Наименование
    end + ';'
  from  PowerObjectUsers
  inner join LegalEntities on LegalEntities.LegalEntityID = PowerObjectUsers.LegalEntityID
  left join Организация on Код_организации = LegalEntities.LegalEntityID
  left join Individuals on IndividualID = LegalEntities.LegalEntityID
  where PowerObjectID = @sourceid
  return @res
end