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

	SELECT @CNT = COUNT(*) 
	FROM MIG_WAREHOUSES 
	WHERE LEN(TYPE_CODE) > 6
	 
	IF @CNT > 1
	BEGIN
		SET @STATUS = 1
		SET @MESSAGE = 'Warehouse Name with length > 6 detected. Correct them.'
	END
	ELSE
	BEGIN
		SET @STATUS = 0
		
		SET @MESSAGE = ''
	END

	SELECT @STATUS, @MESSAGE
END


