After applying my database changes on the test environment, the test team starts testing their processes, one of the things I get is a truncate table error because the table is used in an indexed view.
(1 row(s) affected)
ProductIconTypes ending
ProductImageCategories starting
Msg 3729, Level 16, State 2, Line 1
Cannot TRUNCATE TABLE 'dbo.ProductImageCategories'
because it is being referenced by object 'VWProductImageGetByStyle'.
Questions:
1) next time I want to put an indexed view on one of my databases what exactly I should be checking?
2) Can I get this done through my favourite route (T-SQL)?
I would not mind powershell either.
Unfortunately on these servers in question we are still on SQL Server 2005 AND SQL Server 2008 R2.
A Comment:
These versions impose a lot of limitations on things that we can do as alternatives. Filtered indexes for instance are not available on SQL Server 2005.
I am actually looking for a way if possible to find out what would stop working if I created this indexed view. In my example, the truncate tables could no longer work.
WITH SCHEMABINDING
. Queries should be usingNOEXPAND View Hint
. Remember there is a cost of maintaining indexed views ! Read : technet.microsoft.com/en-us/library/dd171921(v=sql.100).aspxset
options.