When viewing the query plan for a query requiring optimisation (will attach shortly), missing index details were provided. After creating the index and re-running the query a severe error occurs.SELECT TEST_NO, RTRIM( TITLE ) AS TITLE FROM dbo.TEST_TABLE1 WHERE CLASS_NO = 3 AND TEST_TYPE = 'AXB' AND ( DATE_COMPLETED IS NOT NULL OR DATE_COMPLETED <= GETDATE() ) AND ( DATE_DECOMMISSIONED IS NULL OR DATE_DECOMMISSIONED > GETDATE() )GOAfter further investigation we found that the query had a logic error. One of the "OR" should be an "AND" as shown in the script. This resolves our issue and the query works fine however SQL Server should still 'handle' the other scenario.
Version
Category
Operating System
Platform