How can I alter this computed column in SQL Server 2008?

后端 未结 4 1147
傲寒
傲寒 2020-12-07 00:23

I have a computed column created with the following line:

alter table tbPedidos 
add restricoes as (cast(case when restricaoLicenca = 1 or restricaoLote = 1          


        
4条回答
  •  生来不讨喜
    2020-12-07 01:00

    If you're trying to change an existing column, you can't use ADD. Instead, try this:

    alter table tbPedidos alter column restricoes as (cast(case when restricaoLicenca = 1 or restricaoLote = 1 or restricaoValor = 1 then 1 else 0 end as bit))

    EDIT: The above is incorrect. When altering a computed column the only thing you can do is drop it and re-add it.

提交回复
热议问题