|
|
|
SSCommitted
      
Group: General Forum Members
Last Login: Tuesday, April 03, 2012 8:35 AM
Points: 1,608,
Visits: 198
|
|
Thanks, that is what I would have expected. CharIndex would create a situation that invalidates the Index View and basically forces SQL to the underlying tables.
But this does not in itself invalidate the question.
Raymond Laubert Exceptional DBA of 2009 Finalist MCT, MCDBA, MCITP:SQL 2005 Admin, MCSE, OCP:10g
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: 2 days ago @ 7:18 AM
Points: 2,278,
Visits: 2,995
|
|
You have to add the noexpand hint to the query to use the view's index. The noexpand hint forces the optimizer to use the views data instead of the underlying tables and indexes. You have to remember that the optimizer is still cost efficient and sometimes it thinks the using the underlying data is cheaper than using the view data, which may be true in certain cases. Anyway you must use the noexpand hint to make the optimizer look at the view and its indexes only. On the flip side, you can use the expand hint to make the optimizer expand the view.
My blog: http://jahaines.blogspot.com
|
|
|
|
|
Old Hand
      
Group: General Forum Members
Last Login: Friday, July 29, 2011 4:14 AM
Points: 318,
Visits: 198
|
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Monday, May 06, 2013 5:31 AM
Points: 2,226,
Visits: 438
|
|
Ray Laubert (12/8/2009) Thanks, that is what I would have expected. CharIndex would create a situation that invalidates the Index View and basically forces SQL to the underlying tables.
But this does not in itself invalidate the question.
You are right it doesn't invalidate the question, but it is misleading information to everyone trying to create an indexed view with char index, and I think that is a bad.
/Håkan Winther MCITP:Database Developer 2008
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Saturday, September 29, 2012 6:38 AM
Points: 276,
Visits: 21
|
|
What's about this question?
In SQL 2000 - CharIndex is nondeterministic http://msdn.microsoft.com/en-us/library/aa214775(SQL.80).aspx
In SQL 2005 - CharIndex is deterministic http://msdn.microsoft.com/en-us/library/ms178091(SQL.90).aspx
Sorry, but question didn't precise about which version sql server was going.
Please give me my lost point :)
|
|
|
|
|
Ten Centuries
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 9:02 AM
Points: 1,046,
Visits: 573
|
|
Ray Laubert (12/8/2009) Wasn't sure about CharIndex ...Has anyone ever used CharIndex on an indexed view?
But this was not because of the null reason...
What you don't know won't hurt you but what you know will make you plan to know better
|
|
|
|