UFN_DEFAULTCOMMENT_ISUNIQUE

Determine if a Default Comment is unique

Return

Return Type
bit

Parameters

Parameter Parameter Type Mode Description
@ID uniqueidentifier IN
@COMMENTTEXT nvarchar(4000) IN

Definition

Copy


        create function [dbo].[UFN_DEFAULTCOMMENT_ISUNIQUE]
        (
        @ID uniqueidentifier,
        @COMMENTTEXT nvarchar(4000)
        )
        returns bit
        with execute as caller
        as begin
            Declare @CommentCount int
            Declare @IsUnique bit

            set @IsUnique = 1;

            select @CommentCount=count(ID) from DEFAULTCOMMENT where TEXTCOMMENT = @COMMENTTEXT and ID <> @ID;
            if @CommentCount > 0  set @IsUnique=0;

            return @IsUnique
        end