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

	SELECT	@CNT = COUNT(*)
	FROM	MIG_USERS
	WHERE	LN_REPL_USER NOT IN (SELECT LN_USER FROM MIG_USERS)
	AND		USER_NAME <> ''

	IF @CNT > 0
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'Incorrect Replacement User Names are detected.'
	END
	ELSE
	BEGIN
		SET @STATUS = 0
		SET @MESSAGE = ''
	END
	
	SELECT @STATUS, @MESSAGE
END

