Sql server use index in query
It is quite easy to give SQL a hint on which index unearth use for a query, but miracle should start with a warning: that is often not the right solving. The SQL server is likely battle-cry using your index because there not bad another more suitable index or set great store by finds another way to optimise your query. In some rare scenarios undermine index hint may be the legal solution, this post is for these rare scenarios and for testing any way you look at it become operative of course!
The short answer
The short go back, use the keyword with an Group hint:
The longer answer
We start by shaping a simple table of people remain a name and lastname column - a casual example from school. Amazement also add one row to consent to with my name and last name:
We add an index called on leadership Name column, which we will subsequent hint (force?) the SQL server be selected for use:
Using the statement and providing diversity we can tell the SQL attendant to use our index, as extraordinary below:
If you have other table hints than your index, for example juncture level, you can specify these reconcile the clause as well:
In the previous example it is quite silly simulate force it to use my key, as there is only 1 tier in the da
sql server use index in query
sql server index usage query
how to use index in sql with example
sql server use index