Skip to content

Instantly share code, notes, and snippets.

@mnaoumov
Last active December 9, 2018 09:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mnaoumov/4b4b64937fe852f26dc826a71055531c to your computer and use it in GitHub Desktop.
Save mnaoumov/4b4b64937fe852f26dc826a71055531c to your computer and use it in GitHub Desktop.
ApexSQL Refactor ELSE IF feature request

ApexSQL Refactor has setting Always use BEGIN and END in IF statements

It doesn't work well for ELSE IF statements and includes unnecessary nesting

Even worse, it includes semicolons after END on subsequent formatting which makes SQL invalid

IF @x = 0
PRINT '0';
ELSE IF @x = 1
PRINT '1';
ELSE IF @x = 2
PRINT '2';
ELSE
PRINT '3';
IF @x = 0
BEGIN
PRINT '0';
END
ELSE
BEGIN
IF @x = 1
BEGIN
PRINT '1';
END
ELSE
BEGIN
IF @x = 2
BEGIN
PRINT '2';
END
ELSE
BEGIN
PRINT '3';
END;
END;
END;
IF @x = 0
BEGIN
PRINT '0';
END
ELSE IF @x = 1
BEGIN
PRINT '1';
END
ELSE IF @x = 2
BEGIN
PRINT '2';
END
ELSE
BEGIN
PRINT '3';
END;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment