SQL Server 2005 Index Filter Feature

丶灬走出姿态 提交于 2019-12-13 16:08:23

问题


I was told that there is new a feature in SQL Server 2005 called index filters.

What I want to do is add an Index to a column and have the index ignore null values.

I can't find good information on this feature (maybe my source is wrong). Can anyone provide additional information on this feature?


回答1:


CREATE INDEX ix_mytable_mycolumn ON mytable(mycolumn) WHERE mycolumn IS NOT NULL

This will work only in SQL Server 2008, though.

From the docs:

WHERE <filter_predicate>

Creates a filtered index by specifying which rows to include in the index. The filtered index must be a nonclustered index on a table. Creates filtered statistics for the data rows in the filtered index.




回答2:


I think you are speaking about filtered indexes, which were introduced in SQL Server 2008, not 2005.

For information, have a look at this article: http://www.sql-server-performance.com/articles/dba/Filtered_Indexes_in_SQL_Server_2008_p1.aspx

Or just do a google search for "sql server filtered indexes".



来源:https://stackoverflow.com/questions/1560342/sql-server-2005-index-filter-feature

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!