Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Forcing a query to table scan, ignoring the useless index

Status
Not open for further replies.

benhsmith

Programmer
Apr 15, 2002
3
GB
I need to force my query to ignore a useless index and perform a table scan. I think I need to use the 'with' option but can't work out the syntax.
 
Why is the INDEX useless? How do you determine that? If it is useless then SQL Server would not use it. If you feel it is useless, just drop the index.

If you still want to force a table scan use With (Index(0)). This will force a clustered index scan if a clustered index exists or a table scan if there is no clustered index.

Example:

Select *
From TblEmployee With (Index(0))
Where EmpName Like 'smith%' Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top