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
 SQL Server 2000 Forums
 Transact-SQL (2000)
 How to pass index hints through a view?

Author  Topic 

MuadDBA

628 Posts

Posted - 2007-01-30 : 11:36:56
For the purpose of making things easier to refresh, wehave a database set up that is composed of nothing but views pointing to another database, which gets refreshed regularly. In this way, we don't have to script out and re-apply permissions on a regualr basis when we refresh the database.

However, we are encountering a problem where a user wants to supply an index hint to improve the query performance. It doesn't seem to be making it through the view and to the base table. Is there a way to make this work while still refencing the view and not the base table?

snSQL
Master Smack Fu Yak Hacker

1837 Posts

Posted - 2007-01-30 : 17:31:30
No, the user querying the view has no say over what SQL is executed - that's what the view definition is for. You either need to use the hint in the SELECT in the view definition or live with what SQL Server uses. You can specify index hints for queries of views, but they are only used if the view is indexed.
Are you keeping your statistics up to date and rebuilding your indexes regularly - if not then doing so may negate the need for hints.
Go to Top of Page
   

- Advertisement -