Home

Statements should be on separate lines

Rule description

  • Statements should be on separate lines

 

Non-compliant Code Example

DECLARE @Number int;  SET @Number = 50;    --Non compliant code (Declare and Set statements are in the same line)
IF @Number > 100  AND @Number < 200     
    PRINT 'The number is large.';  
ELSE BEGIN IF @Number < 10     --Non compliant code (Else, Begin and If statements are in the same line)
        PRINT 'The number is small.';  
      ELSE  
        PRINT 'The number is medium.';  
   END ;  
GO 

Compliant Code Example

DECLARE @Number int;   --Compliant code
SET @Number = 50;  
IF @Number > 100  AND @Number < 200     
    PRINT 'The number is large.';  
ELSE 
    BEGIN
        IF @Number < 10    --Compliant code
            PRINT 'The number is small.';  
        ELSE  
            PRINT 'The number is medium.';  
   END ;  
GO 
Visual Expert 2020
 VETSQLRULE73