Is is possible? If yes, how?
Here’s the error message I get when trying to create it:
Cannot create index on view “view name” because it references the inline or multistatement table-valued function “function name“. Consider expanding the function definition by hand in the view definition, or not indexing the view.
Look at this list and determine whether your view passes all checkpoints:
The ANSI_NULLS and QUOTED_IDENTIFIER options must have been set to ON
when the CREATE VIEW statement was executed. The OBJECTPROPERTY
function reports this for views through the ExecIsAnsiNullsOn or
ExecIsQuotedIdentOn properties.
The ANSI_NULLS option must have been set to ON for the execution of
all CREATE TABLE statements that create tables referenced by the
view.
The view must not reference any other views, only base tables.
All base tables referenced by the view must be in the same database
as the view and have the same owner as the view.
The view must be created with the SCHEMABINDING option. Schema
binding binds the view to the schema of the underlying base tables.
User-defined functions referenced in the view must have been created
with the SCHEMABINDING option.
Tables and user-defined functions must be referenced by two-part
names in the view. One-part, three-part, and four-part names are not
allowed.
All functions referenced by expressions in the view must be
deterministic. The IsDeterministic property of the OBJECTPROPERTY
function reports whether a user-defined function is deterministic.
For more information, see Deterministic and Nondeterministic
Functions.
Source: here.