0

In SSMS if I create a filtered index we can see filtered condition in index properties. But if I change column type of a column involved in filtered index using SSMS , then after column type changes filtered index condition will be deleted .

For example i created a filtered index for column of datatype varchar(50) . I changed datatype to varchar(100) by using SSMS. After changing datatype I check index properties for that column. Now only filtered condition was missing in properties.

Then I tried to check what may be the reason behind this error. Now when I changed datatype I used "save change script window" and checked what SSMS really does. As we all know the SSMS recreates table index etc , but the index creation query here was missing the filtered condition. Below is part of "save change script window" query showing index creation which does not have filtered condition!!

CREATE NONCLUSTERED INDEX filtered ON dbo.Table_1
(
t
) WITH( STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
GO

So is this bug in SSMS? Or is there anything i am missing like settings in SSMS or anything else?

1 Answer 1

2

When you script the index you need to make sure the scripting option is not set to SQL Server 2005.

Tools / Options / SQL Server Object Explorer / Scripting / Script for server version

enter image description here

I suspect this is the problem (and it happened to me, too).

1
  • In my case it already set to SQL server 2008 R2 . Also I am trying to change the datatype so SSSMS internally creates the script. I think error is in this part.So i rechecked by setting it to sql 2005. Now error comes as u siad while scripting the index using right click on index->script index as ->create to. But if the setting is done for sql 2008 r2 the error mentioned in my question not solves and it does not hav filtered condition.Can you please verify the case I mentioned in my question Commented Nov 5, 2014 at 5:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.