TSQL Parse failed with set tran option and with noexpand

SonarQube Scanner 4.0.0.1744
11.0.3 AdoptOpenJDK (64-bit)
Windows 10 10.0 amd64
SonarQube server 7.9.1

Unable to parse file TSQL file

A. Parser failed in hint option with(noexpand)

17:02:36.973 WARN: Unable to parse file ‘…sql’ : Parse error at line 1247 column 77:

CASE 1:

1244:      select vab.Id --ob.Id
1245:      FROM (SELECT id FROM  dbo.TemplateOutcomeBlocks WITH(FORCESEEK) WHERE TS>=@Ts --AND TS<=@Ts_to 
1246:      UNION SELECT tob_id FROM #ObjectsWithChangedLocalization WHERE tob_id IS NOT NULL ) AS e
1247:                     inner join dbo.viewActiveOutcomeBlocks vab with(noexpand,forceseek) on vab.TemplateOutcomeBlockId = e.Id and vab.FinishBetDate > @ActiveFinishBetDate
                                                                                  ^

CASE 2:

7:03:13.098 WARN: Unable to parse file '.....sql' : Parse error at line 64 column 61:
51:     update ob
52:     set ob.Enabled = ob.Enabled
53:     from dbo.OutcomeBlocks ob
54:     inner join dbo.viewActiveOutcomeBlocks vab with(noexpand) on vab.Id = ob.Id and vab.TemplateOutcomeBlockId = ob.TemplateOutcomeBlockId
                                                                ^

B. Parser failed with set option tran

CASE 1:

17:03:22.313 WARN: Unable to parse file '........sql' : Parse error at line 8 column 5:

 1: SET QUOTED_IDENTIFIER ON
 2: GO
 3: SET ANSI_NULLS ON
 4: GO
 5: Create Procedure [dbo].[PC_View_Orders] (@TopRows Int = 1000, @IsOnline Bit = Null, @DocumentId BigInt = Null)
 6: AS
 7: SET NOCOUNT ON;
 8: SET TRAN ISOLATION LEVEL READ UNCOMMITTED;

CASE 2:

17:03:22.317 WARN: Unable to parse file '.......sql' : Parse error at line 31 column 5:

21:         @CashBookNumber NVARCHAR(200) = NULL,--'1533/8119',
22:         @CheckNumber    VARCHAR(20)   = '00001',
23:         @CheckSession   VARCHAR(20)   = '0160',
24:         @CheckDocDate   DATE          = NULL,
25:         @Amount         MONEY         = NULL,
26:         @PaymentID      INT           = NULL, --96523661;
27:   @Direction int = NULL
28: */
29: 
30: SET NOCOUNT ON;
31: SET TRAN ISOLATION LEVEL READ UNCOMMITTED;
        ^

Hello @ev.khromov,

First, welcome to our community and thanks for reporting this !
Indeed, our TSQL analyzer can sometimes fail to parse statements for some syntaxes.

Regarding what you have reported, I created a new ticket for fixing the NOEXPAND issue: SONARTSQL-247.
Regarding the SET TRAN statement, we have the following open ticket: SONARTSQL-226

Kind regards,
-Chris

Do you know when the NOEXPAND issue ticket SONARTSQL-247 will be released with the current version of sonar scanner? Looks like it has been fixed but I couldn’t determine when the fix will go live.

Hello David,

The fix was deployed on SonarCloud already and will be included in the next SonarQube release (SonarQube 9.8).

Note that the versions of the analyzers are linked to the products (SonarCloud/SonarQube), and not the scanner itself.

Best,
-Chris

1 Like