DF186: GOTO statement is used.

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

Category

BEST PRACTICE

Message

GOTO statement is used.

Description

To improve readability, it is recommended to avoid using the GOTO statement.

Noncompliant code example

DECLARE @Counter int;
SET @Counter = 1;
WHILE @Counter < 10
  BEGIN
    SELECT @Counter AS counter
    SET @Counter = @Counter + 1
    IF @Counter = 4
      BEGIN
        GOTO Branch_One --Jumps to the first branch.
      END
    IF @Counter = 5
      BEGIN
        GOTO Branch_Two --This will never execute.
      END
  END
Branch_One:
  SELECT 'Jumping To Branch One.' AS message
  GOTO Branch_Three; --This will prevent Branch_Two from executing.
Branch_Two:
  SELECT 'Jumping To Branch Two.' AS message
Branch_Three:
  SELECT 'Jumping To Branch Three.' AS message

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?