# Parse error with T-SQL plugin in sonar scanner for SQL files

**URL:** <https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908>\
**Category:** SonarQube Server / Community Build\
**Tags:** parse-error, tsql, sonarqube\
**Created:** [June 18, 2019, 8:32am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908 "2019-06-18T08:32:22Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://community.sonarsource.com/u/Maksim)\
**Post date:** [June 18, 2019, 8:32am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/1 "2019-06-18T08:32:22Z")

</div>

Hello,  
I’m using Developer Edition Version 7.7 (build 23042) with built-in SonarTSQL plugin v1.4 (build 3334) is installed.  
I faced with "WARN: Unable to parse file … : Parse error at line 50 column 13: ", and I’m getting this error for many sql files. These files are skipped from scanning process. These are both large (more then 1300 strings) and small files.  
Could you please advice how to avoid it.  
Screen shots attached  
Thanks.

 ![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/4/40c0ceee7fd743f24a1e4bc0f52249de5fb2d063.png)

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://community.sonarsource.com/u/Maksim)\
**Post date:** [June 18, 2019, 8:33am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/2 "2019-06-18T08:33:04Z")

</div>

![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/2/2e6cee3e0849c17581d22dbffcc3a96892480bbc.png)

---

<div class="post-metadata">

**Author:** ![czurn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/czurn/32/28_2.png) [@czurn](https://community.sonarsource.com/u/czurn)\
**Post date:** [June 21, 2019, 8:36am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/4 "2019-06-21T08:36:19Z")

</div>

Hello Maksim,

Thank you for your feedback!  
To give you some context, when we created our TSQL analyzer, due to the large syntax of the language, we decided to focus on the most commonly used syntax first, so as to bring the most value to our users. We are currently in a phase where we are iteratively improving our analyzer and increasing the number of statements it can parse.

The problem you are facing falls in the case of a syntax we haven’t supported yet: our parser fails to recognize the `$action` keyword inside an expression of an `OUTPUT` clause.  
I created the following ticket for fixing this: [SONARTSQL-229](http://SONARTSQL-229).

Don’t hesitate to report any other parsing issue you encounter, so that we can improve our analyzer even further. Note that you can activate rule [“tsql:S2260 Track parsing failures”](https://rules.sonarsource.com/tsql/RSPEC-2260) in your quality profile on SonarQube to be able to easily monitor and report such errors.

Best,  
-Chris

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://community.sonarsource.com/u/Maksim)\
**Post date:** [June 21, 2019, 4:01pm UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/5 "2019-06-21T16:01:26Z")

</div>

Hello Christophe,  
Thanks for the information.  
Here the results of parsing the file with errors, there are some more new ones, as a picture to keep formatting:

![image](https://europe1.discourse-cdn.com/sonarsource/uploads/sonarcommunity/original/2X/0/0e3231641cb60a7a07a7fa34018cd80555f0a6c5.png)

Thanks in advance

---

<div class="post-metadata">

**Author:** ![czurn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/czurn/32/28_2.png) [@czurn](https://community.sonarsource.com/u/czurn)\
**Post date:** [July 1, 2019, 11:05am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/6 "2019-07-01T11:05:05Z")

</div>

Hello Maksim,

Thanks for the additional feedback!

I created following tickets to address the issues you reported:

Support `CREATE SELECTIVE XML INDEX` statement: [SONARTSQL-230](https://jira.sonarsource.com/browse/SONARTSQL-230)  
Support Scripting variables syntax: [SONARTSQL-231](https://jira.sonarsource.com/browse/SONARTSQL-231)  
Support Service Broker related statements:

- [SONARTSQL-232](https://jira.sonarsource.com/browse/SONARTSQL-232)
- [SONARTSQL-233](https://jira.sonarsource.com/browse/SONARTSQL-233)
- [SONARTSQL-234](https://jira.sonarsource.com/browse/SONARTSQL-234)
- [SONARTSQL-235](https://jira.sonarsource.com/browse/SONARTSQL-235)
- [SONARTSQL-236](https://jira.sonarsource.com/browse/SONARTSQL-236)
- [SONARTSQL-237](https://jira.sonarsource.com/browse/SONARTSQL-237)

For the 3 parse errors on the following snippets:

`:r .\ReferenceData.PostDeployment.sql`

`:r .\Cleanup\PurgeDataHistory.Cleanup.Jobs.sql`

`INDEX [UX_CacheVersions] UNIQUE NONCLUSTERED (...`

I cannot determine what the root causes of these issues are without additional context. If you can share the whole statements causing these errors, it would be great.

Thanks.

Best,  
-Chris

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://community.sonarsource.com/u/Maksim)\
**Post date:** [July 2, 2019, 8:08am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/7 "2019-07-02T08:08:27Z")

</div>

Hello Christophe,  
According to our developers, the use of syntax :r described here: [https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017](https://docs.microsoft.com/en-us/sql/tools/sqlcmd-utility?view=sql-server-2017) .  
**INDEX [UX\_CacheVersions] UNIQUE NONCLUSTERED (…** - this is the same as index creation, but syntax is slightly different and CacheVersions - this is In-memory table.

Thanks,  
Max

---

<div class="post-metadata">

**Author:** ![czurn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/czurn/32/28_2.png) [@czurn](https://community.sonarsource.com/u/czurn)\
**Post date:** [July 3, 2019, 9:06am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/8 "2019-07-03T09:06:58Z")

</div>

Hello Maksim,

The `:r` sqlcmd syntax should already be supported by our parser. For instance, the following snippet can be parsed correctly:

> :r .\ReferenceData.PostDeployment.sql  
> :r .\Cleanup\PurgeDataHistory.Cleanup.Jobs.sql  
> SELECT col1 from myTable;

I suspect the error is coming from the preceding statement. That’s why I would need additional context (1-2 preceding statement(s)) in order to find what is causing the error.

> [@Maksim](#):
>
> this is the same as index creation, but syntax is slightly different and CacheVersions - this is In-memory table.

Our analyzer supports index creation as described in the [documentation](https://docs.microsoft.com/en-us/sql/t-sql/statements/create-index-transact-sql). If the syntax used is different, can you please provide a link to the one you are using. I could not find anywhere a case where the options `UNIQUE` / `NONCLUSTERED` are used after the `INDEX` keyword.

Thanks.

Best,  
-Chris

---

<div class="post-metadata">

**Author:** ![Maksim](https://avatars.discourse-cdn.com/v4/letter/m/ed655f/32.png) [@Maksim](https://community.sonarsource.com/u/Maksim)\
**Post date:** [July 8, 2019, 9:15am UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/9 "2019-07-08T09:15:57Z")

</div>

Hello Christophe,

> [@czurn](#):
>
> If the syntax used is different, can you please provide a link to the one you are using.

> **[CREATE TABLE (Transact-SQL) - SQL Server](https://learn.microsoft.com/en-us/sql/t-sql/statements/create-table-transact-sql?view=sql-server-2017)**
>
> CREATE TABLE (Transact-SQL)

> [@czurn](#):
>
> The `:r` sqlcmd syntax should already be supported by our parser.

Since T-SQL plugin is built-in, should I update SonarQube to 7.9?

---

<div class="post-metadata">

**Author:** ![czurn](https://dub1.discourse-cdn.com/sonarsource/user_avatar/community.sonarsource.com/czurn/32/28_2.png) [@czurn](https://community.sonarsource.com/u/czurn)\
**Post date:** [July 8, 2019, 12:36pm UTC](https://community.sonarsource.com/t/parse-error-with-t-sql-plugin-in-sonar-scanner-for-sql-files/10908/10 "2019-07-08T12:36:14Z")

</div>

Hello Maksim,

Thanks for the link. Indeed, I could reproduce the parsing error when attempting to create a `UNIQUE` index inside a `CREATE TABLE` statement. Here’s the related ticket: [SONARTSQL-239](https://jira.sonarsource.com/browse/SONARTSQL-239).

> [@Maksim](#):
>
> Since T-SQL plugin is built-in, should I update SonarQube to 7.9?

It is not necessary to update SonarQube version to get the latest version of the TSQL plugin. You can follow the normal procedure to update/install a plugin from the [marketplace](https://docs.sonarqube.org/latest/instance-administration/marketplace/) to update to the latest version of SonarTSQL plugin.  
However from what you mentioned in your first post:

> [@Maksim](#):
>
> I’m using Developer Edition Version 7.7 (build 23042) with built-in SonarTSQL plugin v1.4 (build 3334) is installed.

You are already using the latest version of our plugin.

As mentioned in my previous post, the parse error is most likely due to the previous statement(s?). If you can either share the previous statement or a self-contained reproducer, that would help us determine the root of the error.

Best,  
-Chtis
