LISTING 2: Creating the complex_valid Rule and Binding It to the Complex Type CREATE rule complex_valid AS -- Check whether last character is 'i'. RIGHT(RTRIM(@cx), 1) = 'i' AND IsNumeric(LEFT(LTRIM(@cx), PATINDEX('%_[-+]%', LTRIM(@cx)))) = 1 AND IsNumeric(SUBSTRING(LTRIM(@cx), PATINDEX('%_[-+]%', LTRIM(@cx)) + 1, LEN(RTRIM(LTRIM(@cx))) - PATINDEX('%_[-+]%', LTRIM(@cx)) - 1)) = 1 GO EXEC sp_bindrule 'complex_valid', 'complex' GO