SA0177 : To improve code readability, put only one statement per line |
![]() |
Placing multiple T-SQL statements on the same line can reduce code clarity and increase the risk of errors, making it essential to separate each statement for better readability and maintainability.

Writing more than one SQL statement on a single line can create difficulties in code readability and maintenance. This practice can obscure the logic of the query, making it harder for developers and administrators to identify individual statements, especially when debugging or extending the query.
For example:
1-- Example of problematic query 2SELECT * FROM Employees; UPDATE Employees SET IsActive = 1 WHERE EmployeeID = 1;
This line includes both a SELECT and an UPDATE statement, which can be confusing for others reviewing the code. Furthermore, it can lead to errors being overlooked, as automated tools and scripts may not always parse combined statements correctly.
-
This approach can reduce code readability, making it tough to understand the individual operations being performed.
-
Combining statements on a single line increases the risk of syntax errors and makes it harder to spot bugs during debugging.

@@_SHFB_2

The rule has a Batch scope and is applied only on the SQL script.

Rule has no parameters.

The rule does not need Analysis Context or SQL Connection.


Design Rules, Code Smells

There is no additional info for this rule.

SQL
1CREATE TABLE Test.Greeting 2( 3GreetingId INT IDENTITY (1,1) PRIMARY KEY, 4Message nvarchar(255) NOT NULL, 5) 6 7INSERT INTO Test.Greeting (Message) SELECT 'Hello!' UNION ALL SELECT 'Hi!' UNION ALL SELECT 'Hello, world!' 8 9INSERT INTO Test.Greeting (Message) 10VALUES ('How do yo do?'), 11 ('Good morning!'), 12 ('Good night!') SELECT * FROM Test.Greeting g 13WHERE 14g.Message like 'Hello%' 15 16DELETE Test.Greeting WHERE GreetingId = 3; DROP TABLE Test.Greeting |

Message | Line | Column | |
---|---|---|---|
1 | SA0177 : To improve code readability, put only one statement per line. | 16 | 0 |
2 | SA0177 : To improve code readability, put only one statement per line. | 16 | 45 |
