Skip to content

Instantly share code, notes, and snippets.

@ArCiGo
Created May 20, 2019 00:29
Show Gist options
  • Save ArCiGo/1b9c8acf383df0a2f12aa6334f5076a2 to your computer and use it in GitHub Desktop.
Save ArCiGo/1b9c8acf383df0a2f12aa6334f5076a2 to your computer and use it in GitHub Desktop.
CREATE NONCLUSTERED INDEX IDX_Orders ON [ORDER](OrderDate);
GO
SELECT *
FROM [ORDER] ord
WITH (INDEX(IDX_Orders))
WHERE ord.OrderDate BETWEEN '20120828' AND '20120830';
GO
/** Output **/
Id OrderDate OrderNumber CustomerId TotalAmount
----------- ----------------------- ----------- ----------- ---------------------------------------
45 2012-08-28 00:00:00.000 542422 81 1296.00
46 2012-08-29 00:00:00.000 542423 80 848.70
47 2012-08-30 00:00:00.000 542424 65 1887.60
DROP INDEX IDX_Orders ON [ORDER];
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment