would really love to save space and use a filtered index on a computed column

db042190 1,521 Reputation points
2022-03-24T12:14:58.88+00:00

hi we run 2019 and have the 2 following columns defined on a number of tables...

[ROW_VERSION_STAMP] [timestamp] NOT NULL,
[ROW_VERSION_NUMBER] AS (CONVERT([bigint],[ROW_VERSION_STAMP])),

we'd like an index on the second but only starting at a certain value. ie a filtered index. we get an error (shown below) attempting to build such an index. is there a workaround? i'm even thinking about building it instead on the binary(8) timestamp.

Filtered index 'revise' cannot be created on table 'dbo.revised1' because the column 'ROW_VERSION_NUMBER' in the filter expression is a computed column. Rewrite the filter expression so that it does not include this column.

Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
0 comments No comments
{count} votes

6 answers

Sort by: Most helpful
  1. db042190 1,521 Reputation points
    2022-03-29T14:50:17.937+00:00

    this gets confusing. at https://learn.microsoft.com/en-us/answers/questions/784633/generating-a-script-for-building-a-new-index-on-a.html#answer-791781 erland posted a sample where he was able to create a filtered index on a computed column. i posted a sample there where i got an error. so far the differences are that i have a timestamp and bigint. and i think he used ints. i wonder if he has one of those other legacy settings maybe on or off? and maybe i have the opposite.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.