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

	SELECT	@CNT = COUNT(*)
	FROM	MIG_USERS
	GROUP BY LN_USER
	HAVING COUNT(LN_USER)>1

	IF @CNT > 0
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'Duplicate User Names are detected. Correct them via Fix User ID''s Tab.'
	END
	ELSE
	BEGIN
		SET @STATUS = 0
		SET @MESSAGE = ''
	END
	
	SELECT @STATUS, @MESSAGE
END

