TSQL Rule to warn when cursors are created

Hi everybody.
At our organization, we recently bought SonarQube Enterprise Edition. Now we have version 8.5.1 installed. We had notice that the TSQL plugin is lacking one very important rule that we have to enforce: to warn when a CURSOR is created. Please, SonarQube team, can you help us with this rule?

description of the Rule: A warning must be issued on CURSOR creation. As everybody knows and is well documented, creation of SQL cursors should be avoided and only used when it’s impossible to find a more efficient way to solve a problem. Must cursors can and should be replaced using Common Table Expresions, temporary tables, joins, WHILE statements or even a single SELECT statement. SQL cursors have a extremely poor performance and should be avoided at all in large databases. At our organization (a bank), the use of cursors is forbidden by DBAs.

In general, the use of cursors should be avoided at all when dealing with large tables. In the case of small tables, there are no major performance drawbacks, but more efficient solutions often exist.

Thanks a lot for your attention.
Best regards,
Jorge

Thanks a lot for this suggestion!
We are going to evaluate whether it makes sense to include such a rule in our T-SQL analyzer.

Best regards,
Pierre-Yves

Thanks a lot to you, Pierre, we’ll be waiting for updates about this topic.

Best regards,
Jorge