Sonarscanner failed to scan a tsql file with parse error

Hi I just installed sonarqube developer edition yesterday and installed latest sonar scanner to scan my sql server code using sonarTSQL code analyzer.
I simply tried to scan sample code but getting below error and stopped scanning further. Below is the error from sonar scanner. Appreciate any help.

WARN: Unable to parse file 'C:/ 001-1-DDL_app_test_lnr.tsql' : Parse error at line 2 column 30:
 
1:
2:  CREATE FUNCTION my_function RETURN PLS_INTEGER AS
                                                                 ^
3: BEGIN
4:   RETURN 42;

Hi Hari,

If I add β€œ()” after function name, β€œS” at RETURN and β€œEND” at the end, the code is parsed by SonarTSQL without error.

CREATE FUNCTION my_function() RETURNS PLS_INTEGER AS
BEGIN
RETURN 42;
END

And it matches specification: https://docs.microsoft.com/en-us/sql/t-sql/statements/create-function-transact-sql?view=sql-server-2017

Could you execute your tsql file on your SQL Server to check if there is a syntax error?
Which is your SQL Server version?

Regards,
Alban

1 Like