QuestionQ88
VerifiedSecure, optimize, and deploy database solutionsYou have an Azure SQL database that supports an AI-enabled product catalog API. The database includes a table named Sales.Orders. Sales.Orders contains 20 million rows and has a nonclustered index on a column named CreateDate.
The API supplies a date parameter named @OrderDate.
You have a stored procedure named get_latest_day_orders that filters by executing the following query:
WHERE CAST(CreateDate AS date) = @0rderDate.
A review of the query execution shows that the query performs an index scan.
You need to change the predicate so that Microsoft SQL Server can use an index seek on CreateDate for a single day.
Which WHERE clause should you use?
Community Discussion