1.Parse error in String Aggregate function[Within group section] Sample Snippet:
SELECT Distinct column1, column2+ ’ ’ + STRING_AGG(col3, ', ') WITHIN GROUP (ORDER BY col4 ASC) AS colm,
^
2.Parse error in multiline comment section Sample Snippet:
/*select col1, col2 from tbl
where col1=" "
select col1, col2 from tbl
where col1=" "
/*select col1, col2 from tbl
where col1=" "
*/
Usually this kind of comments section can be parsed in MS SQL
3.Parse error in keyword “union”
Sample Snippet: Select Top 13 empname, empdesg from
(select Top 13 personname, person desgn from person where cond1
order by personname desc
union
select Top 13 personname, person desgn from person where cond2
order by personname desc) a
Nested comments are supported. If the /* character pattern occurs anywhere within an existing comment, it is treated as the start of a nested comment and, therefore, requires a closing */ comment mark. If the closing comment mark does not exist, an error is generated.
If I run your snippet, SQL Server 14 fails with:
Missing end comment mark '*/'
Again, it seems that your snippet is not accepted by SQL Server, I get:
Reg.Point 3: I am having same kind of queries in my application. But, all are working in sql server.
I have shared screenshot of sample screenshot of same snippet. It can be parsed in sql server whereas it is failed in sonar scanner.
You’re right, SQL Server seems to execute your query without any problem.
I must have made a mistake when testing it the first time, sorry for that.
It seems that SQL Server accepts ORDER BY...UNION for a subquery but raises an error for a top-level query.
I created SONARTSQL-249 to track the issue.