views:

42

answers:

3

Is it possible to create unclustered indexes in SQL Server 2005 that are not updated as data is changed (insert/delete/udpate) so I can ensure a stable set of data to report on?

Our data is changing frequently an I want to be able to snapshot it at a point with out having a column to show the latest change date/time and only selecting data based on that. Before I perform my analysis, I could update them and use them from that point forward.

A: 
Randolph Potter
-1 Turning off statistics causes the query optimizer to use a suboptimal plan, but updates or inserts will still make it into the index. A disabled index cannot be used for anything, including reporting
Andomar
Fair enough. I'll defer to your answer.
Randolph Potter
+2  A: 

I don't think you can tell an index to remain stale. A separate reporting table would be more appropriate solution.

For example, you can load a snapshot into a new reporting table like:

truncate table BigTableSnapshot

select *
from BigTable
into BigTableSnapshot

Alternatively, SQL Server Enterprise Edition allows you to take snapshots of an entire database. That can be very useful for reporting, although it does have a performance impact.

Andomar
Its not quite the solution that I was looking for but I think that its the best that you can get in SQL Server. Thanks.
Penfold
+1  A: 

If you have the Enterprise version of SQL2005 you can snapshot the whole database giving you a read-only / static point in time copy of the database to report against.

http://msdn.microsoft.com/en-us/library/ms175158.aspx

SuperCoolMoss
Sorry Andomar, I didn't read you answer properly and see that you've already pointed this out.
SuperCoolMoss
@SuperCoolMoss: It's okay to post multiple answers! The voters can decide which one explains it better
Andomar