Home

Conditionals should start on new lines

Rule description

  • Conditionals should start on new lines

 

Non-compliant Code Example

DECLARE @Number int;  
SET @Number = 50;  
IF @Number > 100  PRINT 'The number is large.';  --Non compliant code (Conditionals should start on new lines)
ELSE   
   BEGIN  IF @Number < 10  --Non compliant code (Conditionals should start on new lines)
      PRINT 'The number is small.';  
   ELSE  
      PRINT 'The number is medium.';  
   END ;  
GO 

Compliant Code Example

DECLARE @Number int;  
SET @Number = 50;  
IF @Number > 100  --Compliant code (Conditional is starting in the new line)
   PRINT 'The number is large.';  
ELSE   
   BEGIN  
      IF @Number < 10  --Compliant code (Conditional is starting in the new line)
      PRINT 'The number is small.';  
   ELSE  
      PRINT 'The number is medium.';  
   END ;  
GO 
Visual Expert 2020
 VETSQLRULE10