我正在使用sql Server 2008.可以更改计算列而不实际删除列,然后再次添加(我可以上班)?例如,我有这个表:
CREATE TABLE [dbo].[Prices]( [Price] [numeric](8,3) NOT NULL,[AdjPrice] AS [Price] / [AdjFactor],[AdjFactor] [numeric](8,3) NOT NULL)
后来意识到我有一个零错误的潜在差距,我想改变[Adjprice]列来处理这个,但如果我只是删除列并再次添加,我失去了列顺序.
我想做一些像:
ALTER TABLE dbo.[Prices] ALTER COLUMN [AdjPrice] AS (CASE WHEN [AdjFactor] = 0 THEN 0 ELSE [Price] / [AdjFactor] END)