对象名称无效 'CHANGETABLE'

Invalid object name 'CHANGETABLE'

我刚刚通过打开 ALLOW_SNAPSHOT_ISOLATION 来启用更改跟踪,执行此查询以打开数据库的更改跟踪

ALTER DATABASE [DatabaseName] 
SET CHANGE_TRACKING = ON (CHANGE_RETENTION = 2 DAYS,AUTO_CLEANUP = ON)

并最终在 table

上启用它
ALTER TABLE [TableName] 
ENABLE CHANGE_TRACKING WITH (TRACK_COLUMNS_UPDATED = OFF)

现在当我打电话给

SELECT * 
FROM CHANGETABLE(CHANGES, 0)

我收到此错误消息:

Invalid object name 'CHANGETABLE'.

数据库版本是SQLServer 2012,CHANGETABLE怎么会失效,怎么才能生效呢?我认为它会开箱即用,因为它是一个系统功能。它甚至在 SQL Server Management Studio 中突出显示。我在打开更改跟踪和调用 CHANGETABLE().

之间修改了一点数据

correct syntax

SELECT * FROM CHANGETABLE(CHANGES MyTableName,@last_version) as SomeAlias

这显示在 documentation examples 中:

DECLARE @last_sync_version bigint;  
SET @last_sync_version = <value obtained from query>;  

SELECT [Emp ID], SSN,  
    SYS_CHANGE_VERSION, SYS_CHANGE_OPERATION,  
    SYS_CHANGE_COLUMNS, SYS_CHANGE_CONTEXT   
FROM CHANGETABLE (CHANGES Employees, @last_sync_version) AS C;

忘记 table 名称会导致 Invalid object name 'CHANGETABLE'

忘记 table 别名会导致 A table returned by the CHANGETABLE function must be aliased.