-- EXEC MIG_VALIDATE_DUPLICATE_DOC_TYPE_SHORT_DESC_Sp 
CREATE OR ALTER PROCEDURE MIG_VALIDATE_DUPLICATE_DOC_TYPE_SHORT_DESC_Sp
(
	@STATUS INT = 0 OUT,
	@MESSAGE NVARCHAR(999) = NULL OUT
)
AS
BEGIN

	DECLARE @CNT INT
	SET @CNT = 0

	SELECT @CNT = COUNT(SHORT_DESCR)
	FROM ZZ_UDCDTYPE
	WHERE TYPE_NAME LIKE '%DOC_TYPE%'
	GROUP BY SHORT_DESCR HAVING COUNT(SHORT_DESCR) > 1

	--PRINT(@CNT)

	IF @CNT = 0
	BEGIN
		SET @STATUS = 0
		SET @MESSAGE = ''

	END
	ELSE
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'DOCUMENT_TYPE (DOC_TYPE) have duplicate entries.'
	END

	SELECT @STATUS, @MESSAGE

END

