如何在SQL Server 2008中更改此计算列? [英] How can I alter this computed column in SQL Server 2008?
本文介绍了如何在SQL Server 2008中更改此计算列?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我用以下行创建了一个计算列:
I have a computed column created with the following line:
alter table tbPedidos
add restricoes as (cast(case when restricaoLicenca = 1 or restricaoLote = 1 then 1 else 0 end as bit))
现在我需要将此列更改为以下内容:
But, now I need to change this column for something like:
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))
但这不起作用。我正在尝试向case语句输入另一个条件,但是它不起作用。
But it's not working. I'm trying to input another condition to the case statement, but it's not working.
非常感谢!
推荐答案
如果要更改现有列,则不能使用ADD。而是尝试以下操作:
If you're trying to change an existing column, you can't use ADD. Instead, try this:
更改表tbPedidos
更改列的限制为
(强制转换(当restricaoLicenca = 1时或restricaoLote = 1或restricaoValor = 1
然后1 else 0结尾为位))
编辑:上面是<强烈不正确。更改计算列时, 唯一可以做的就是删除它并重新添加它。
The above is incorrect. When altering a computed column the only thing you can do is drop it and re-add it.
这篇关于如何在SQL Server 2008中更改此计算列?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文