Is it possible to index a persisted field?
When trying to change a primary key to a persisted field or
add a primary key to a field I’ve made persisted field I get the following:
Cannot define PRIMARY KEY constraint on nullable column in table
‘tblOpportunityRecords’.
In order to male your computed field non-null, you need to help SQL Server figure out that no nulls are possible. Usually, this is done using the
ISNULLfunction which can be used to ensure that the resulting expression is non-nullable.Note, that you can’t use the
COALESCEfunction (for a reason unknown to me – it just doesn’t work).