Tuesday, 19 July 2016

SQL Server - How to create a view with an index

Creating views with index

create view vw_ukhd_english_postcodes
WITH SCHEMABINDING as
  select
    Char_8_ASCII_Index
  from
    ODS.Postcode_Grid_Refs_Eng_Wal_Sco_And_NI_SCD
  where
    is_latest = 1
    and substring(country, 1,1) = 'E'

create unique clustered index pk_ukhd_country on vw_ukhd_english_postcodes(Char_8_ASCII_Index)

No comments:

Post a Comment