Error en consulta

tema enviado por feli en SQL
tema iniciado el 25/07/2014
buen día tengo la siguiente consulta en SQL server 2008 r2 DECLARE @cColour NVARCHAR(20), @cLeaf NVARCHAR(20), @cLenght NVARCHAR(20), @cMicronaire NVARCHAR(20), @cStrength NVARCHAR(20), @cRd NVARCHAR(20), @cUniformity NVARCHAR(20), @QualityType NVARCHAR(MAX) SET @cColour = '0' SET @cLeaf = '2' SET @cLenght = '1.21' SET @cMicronaire = '4.9' SET @cStrength = '31.4' SET @cRd = '80.1' SET @cUniformity = '83' IF @cRd = '' BEGIN SET @cRd = '0' END IF @cUniformity = '' BEGIN SET @cUniformity = '0' END SET @QualityType = '' SET @QualityType = (SELECT [Quality (Type)] FROM [Quality Criterias] WHERE [CMS Dimension 1 Code] = 31 AND CAST(@cColour AS DECIMAL(18,2)) <> 0 AND [Low Grade] <= (CAST(@cColour AS DECIMAL(18,2))) AND [High Grade] >= (CAST(@cColour AS DECIMAL(18,2))) AND CAST(@cLeaf AS DECIMAL(18,2)) <> 0 AND [Low Leaf] <= (CAST(@cLeaf AS DECIMAL(18,2))) AND [High Leaf] >= (CAST(@cLeaf AS DECIMAL(18,2))) AND CAST(@cLenght AS DECIMAL(18,2)) <> 0 AND [Low HVI Length] <= (CAST(@cLenght AS DECIMAL(18,2))) AND [High HVI Length] >= (CAST(@cLenght AS DECIMAL(18,2))) AND CAST(@cMicronaire AS DECIMAL(18,2)) <> 0 AND [Low Micronaire] <= (CAST(@cMicronaire AS DECIMAL(18,2))) AND [High Micronaire] >= (CAST(@cMicronaire AS DECIMAL(18,2))) AND CAST(@cStrength AS DECIMAL(18,2)) <> 0 AND [Low Strength] <= (CAST(@cStrength AS DECIMAL(18,2))) AND [High Strength] >= (CAST(@cStrength AS DECIMAL(18,2))) AND CAST(@cRd AS DECIMAL(18,2)) <> 0 AND [Low Rd] <= (CAST(@cRd AS DECIMAL(18,2))) AND [High Rd] >= (CAST(@cRd AS DECIMAL(18,2))) AND CAST(@cUniformity AS DECIMAL(18,2)) <> 0 AND [Low uniformity] <= (CAST(@cUniformity AS DECIMAL(18,2))) AND [High uniformity] >= (CAST(@cUniformity AS DECIMAL(18,2)))) IF @QualityType = '' BEGIN SET @QualityType = 'EZA' END print @QualityType El problema es que no entra al ultimo IF si la condición se cumple IF @QualityType = '' BEGIN SET @QualityType = 'EZA' END Y no asigna el valor EZA a mi variable. Espero me puedan ayudar. Saludos.