DF032: A control-of-flow statement is not defined by using a statement block.

The topic describes the DF032 T-SQL code analysis rule.

Category

BEST PRACTICE

Message

A control-of-flow statement is not defined by using a statement block.

Description

It is recommended to use the BEGIN…END keywords to enclose control-of-flow statements into a statement block.

Additional information

The nested IF-ELSE clause doesn’t need to be enclosed by the BEGIN and END keywords. However, the IF clause must be wrapped by the BEGIN and END keywords.

Noncompliant code example

IF @Var1=1 SELECT '1' AS Result ELSE SELECT '2' AS Result

Compliant solution

IF @Var1=1 BEGIN
  SELECT '1' AS Result
END ELSE BEGIN
  SELECT '2' AS Result
END

Want to Find out More?

Overview

Overview

Take a quick tour to learn all about the key benefits delivered by dbForge Studio for SQL Server.
All Features

All features

Get acquainted with the rich features and capabilities of the Studio in less than 5 minutes.
Request a demo

Request a demo

If you consider employing the Studio for your business, request a demo to see it in action.
Ready to start using dbForge Studio for SQL Server?