When are computed columns appropriate?

后端 未结 6 1870
渐次进展
渐次进展 2021-02-04 12:54

I\'m considering designing a table with a computed column in Microsoft SQL Server 2008. It would be a simple calculation like (ISNULL(colA,(0)) + ISNULL(colB,(0))) - like a tot

6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-02-04 13:39

    Computed columns can be appropriate if you plan to query by that information.

    For instance, if you have a dataset that you are going to present in the UI. Having a computed column will allow you to page the view while still allowing sorting and filtering on the computed column. if that computed column is in code only, then it will be much more difficult to reasonably sort or filter the dataset for display based on that value.

提交回复
热议问题