devxlogo

Tip: T-SQL Performance–NOT IN vs NOT EXISTS

Tip: T-SQL Performance–NOT IN vs NOT EXISTS

Avoid using NOT IN whilst comparing nullable columns. Use NOT EXISTS instead.

When NOT IN is used in a query, SQL Server compares each result to null (even if no rows are returned). NOT EXISTS does not perform a comparison with nulls.

?

Visit the DevX Tip Bank

?

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist