Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 constrain sql server to use certain index

Author  Topic 

landau66
Yak Posting Veteran

61 Posts

Posted - 2008-06-16 : 05:36:40
Hello everyone!

How can I constrain (force) sql server 2005 to use a certain index though by default it wouldnt use this one??

Thanks in advance and greetings from vienna

landau66

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-06-16 : 05:39:33
you can use With (Index (indexname))

select *
FROm Table1
INNER JOIN Table2 With (Index (indexname))
ON fields
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2008-06-17 : 02:59:01
Make sure you test carefully to ensure that the forced index does perform better than the default. Test again every few months to make sure that data volume changes haven't made the forced index less efficient.

Also, be aware that if you drop the index, your query will throw errors.

--
Gail Shaw
Go to Top of Page
   

- Advertisement -