SQL Anti-Patterns Overview
SQL Anti-Patterns Overview
Using SELECT *
Using SELECT *
SELECT *
in production code. Instead, explicitly list the columns you need. This improves performance by reducing I/O and network traffic, prevents issues when table schemas change, and makes your code more maintainable by clearly showing which columns are being used.Not Using Parameterized Queries
Not Using Parameterized Queries
Inefficient Joins
Inefficient Joins
Not Using Indexes Properly
Not Using Indexes Properly
Using DISTINCT Unnecessarily
Using DISTINCT Unnecessarily
Using Cursors Instead of Set-Based Operations
Using Cursors Instead of Set-Based Operations
Not Using Appropriate Data Types
Not Using Appropriate Data Types
Storing Comma-Separated Values
Storing Comma-Separated Values
Not Using Transactions
Not Using Transactions
Using NOT IN with NULL Values
Using NOT IN with NULL Values
Using COUNT(*) to Check Existence
Using COUNT(*) to Check Existence
Using OFFSET for Pagination
Using OFFSET for Pagination
Using OR Conditions on Different Columns
Using OR Conditions on Different Columns
Not Using Common Table Expressions (CTEs)
Not Using Common Table Expressions (CTEs)
Using Implicit Conversions
Using Implicit Conversions
Using Scalar User-Defined Functions in WHERE Clauses
Using Scalar User-Defined Functions in WHERE Clauses
Not Using Schema Names
Not Using Schema Names
Using Table Variables When Temporary Tables Would Be Better
Using Table Variables When Temporary Tables Would Be Better
Using DELETE Without WHERE
Using DELETE Without WHERE
Not Using MERGE for Upserts
Not Using MERGE for Upserts
Using Non-Standard SQL
Using Non-Standard SQL
Not Using Appropriate Constraints
Not Using Appropriate Constraints