If you want to make sure that the metadata about a view is always accurate, use the SCHEMABINDING
option when you create it:
Binds the view to the schema of the underlying table or tables. When
SCHEMABINDING
is specified, the base table or tables cannot be modified in a way that would affect the view definition. The view definition itself must first be modified or dropped to remove dependencies on the table that is to be modified. When you useSCHEMABINDING
, the select_statement must include the two-part names (schema.object) of tables, views, or user-defined functions that are referenced. All referenced objects must be in the same database.