How to create a filtered index

This is the quick-and-dirty method of creating a filtered index:

T-SQL
USE [AdventureWorks2012]
GO
SET ANSI_PADDING ON
GO
CREATE NONCLUSTERED INDEX [NC_Person_Address_City_spi_pc] ON [Person].[Address] ([City] ASC) INCLUDE ([StateProvinceID], [PostalCode])
WHERE [City] = ‘Seattle’ ON [PRIMARY] GO

You can find more about filtered indexes on Introduction to SQL Server Filtered Indexes by Seth Delconte

Advertisements