2

The ORM we are using (LLBL) does not easily support the NOEXPAND keyword on selecting from SQL Server Indexed Views, which, as I understand it, pretty much negates the purpose of the Indexed View.

I normally steer clear from Stored Procedures for a few reasons (that I will attempt to avoid a flame war by not mentioning), so my hesitation at this point, I admit, is partly due to a lack of recent working experience with SQL Server and Stored Procedures.

Is there anything I need to be aware of that would cause the Indexed View not to work if I called it from a Stored Procedure.

johnc
  • 39,385
  • 37
  • 101
  • 139

1 Answers1

2

Is there anything I need to be aware of that would cause the Indexed View not to work if I called it from a Stored Procedure.

No! Indexed Views are works fine when you call them from a SP. You can use Indexed Views like a normal table in many (not 100% sure whether all) cases.

CharithJ
  • 46,289
  • 20
  • 116
  • 131
  • Thanks, that was my gut feel, but I thought it best to check – johnc Aug 29 '11 at 23:24
  • 1
    I've recently done this and it works fine. Some additional info... In my case TableValuedFunctions performed better than IndexedViews. I am not telling you to change the IndexedView to a TableValue function. Just some food to think :-) – CharithJ Aug 29 '11 at 23:28
  • I think llbl is obtuse about functions as it is about indexed views :) – johnc Aug 29 '11 at 23:33
  • 2
    @CharithJ that all depends on what the indexed view does, how the TVF replicates that, and whether you can even write a TVF that is equivalent. I've implemented several cases where indexed views beat TVFs hands down, at least at query time. Keep in mind that you do pay for index maintenance for an indexed view when writing data, which doesn't occur with TVFs obviously. – Aaron Bertrand Aug 30 '11 at 00:54