UFN_EDUCATIONALINSTITUTION_NAMEISUNIQUE

Make sure that an educational institutions name is unique.

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@EDUCATIONALINSTITUTIONID uniqueidentifier IN
@NAME nvarchar(100) IN

Definition

Copy


      CREATE function dbo.UFN_EDUCATIONALINSTITUTION_NAMEISUNIQUE
      (
        @EDUCATIONALINSTITUTIONID uniqueidentifier,
        @NAME nvarchar(100)
      )
      returns bit
      with execute as caller
      as begin
          declare @RETVAL bit = 1;

        if (exists (select EDUCATIONALINSTITUTION.ID
                    from dbo.EDUCATIONALINSTITUTION
                      inner join dbo.CONSTITUENT
                        on EDUCATIONALINSTITUTION.ID = CONSTITUENT.ID
                    where (EDUCATIONALINSTITUTION.ID != @EDUCATIONALINSTITUTIONID) and
                          (CONSTITUENT.KEYNAME = @NAME)))
        begin
          set @RETVAL = 0;
        end

          return @RETVAL;
      end