我需要将已配置为GENERATED ALWAYS
的现有表列更改为GENERATED BY DEFAULT
。
样本表结构
CREATE TABLE [dbo].[Contact](
[ContactID] [uniqueidentifier] NOT NULL,
[ContactNumber] [nvarchar](50) NOT NULL,
[SequenceID] [int] IDENTITY(1,1) NOT NULL,
[SysStartTime] [datetime2](0) GENERATED ALWAYS AS ROW START NOT NULL,
[SysEndTime] [datetime2](0) GENERATED ALWAYS AS ROW END NOT NULL,
CONSTRAINT [PK_Contact] PRIMARY KEY NONCLUSTERED
(
[ContactID] ASC
)WITH (PAD_INDEX = OFF,
STATISTICS_NORECOMPUTE = OFF,
IGNORE_DUP_KEY = OFF,
ALLOW_ROW_LOCKS = ON,
ALLOW_PAGE_LOCKS = ON)
ON [PRIMARY],
PERIOD FOR SYSTEM_TIME ([SysStartTime], [SysEndTime])
) ON [PRIMARY]
WITH
(
SYSTEM_VERSIONING = ON (HISTORY_TABLE = [dbo].[ContactHistory],
DATA_CONSISTENCY_CHECK = ON )
)
这是我现在已经拥有的表我需要更改列
来自[SysStartTime]
GENERATED BY DEFAULT
到GENERATED ALWAYS
我尝试了以下代码
ALTER TABLE dbo.Contact ALTER column SysStartTime SET GENERATED BY DEFAULT
但它会抛出错误
消息156,级别15,状态1,行19关键字附近的语法不正确 'SET'。
请帮助我。