将特定的硬编码值添加到计算列中的某些行

Add specific hardcoded values to some rows in a computed column

是否可以更改计算列的某些值?我们需要它,因为这些值连接到另一个系统并且必须更改其中三个。

我们的计算列如下所示:

('Product-'+CONVERT([NVARCHAR](100),(1000)+[Id],(0)))

我现在必须将值 Product-1356Product-1655Product-1701 更改为 Product-12Product-17Product-18(示例值).这三个必须硬编码。其余的必须像以前一样计算。

我尝试使用 T-SQL:

正常更新它
UPDATE MyTable
SET ProductId = 'Product-12'
WHERE ProductId = 'Product-1356'

但现在我收到以下错误:

The column "ProductId" cannot be modified because it is either a computed column or is the result of a UNION operator.

更新 Id 列也不起作用,因为它是主键:

Cannot update identity column 'Id'.

我该怎么做?有可能吗?

我能想到的两个方案:

  1. 删除这些行并使用正确的 ID 重新添加它们。
  2. 设置新的 ProductIdOverride 列并将所有硬编码 ID 放在那里。如果您希望使用现有公式,请保留 Null。然后将您的计算列更改为 COALESCE(ProductIdOverride, ('Product-'+CONVERT([NVARCHAR](100),(1000)+[Id],(0))))