Rule Definition
Complex select clauses, i.e select clauses with many column can be difficult to read and does not help the reader who needs to identify the relevant columns to be retrieved.
Also a query that retrieves many columns can potentially cause performance problems:
Such performance problems may arise when the execution of the query returns a large result sets (many row with many colums may then become a huge amount of data to transport over the network).
Remediation
Review the SELECT statement to reduce the number of selected columns.
Violation Code Sample
Create Procedure Return_Columns As
Begin
Select col1, col2, col3, col4, col5, col6, col7, col8, col9, col10
from table1, table2, table3
where id = 1
End
GO
Fixed Code Sample
Create View Return_Columns As
Select col1, col2, col3, col4, col5, col6, col7, col8, col9, col10
from table1, table2, table3
where id = 1
GO
Related Technologies
Technical Criterion
Complexity - SQL Queries
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.