SQL 服务器同时为 table 更改跟踪和更改数据捕获
SQL Server's Change Tracking and Change Data Capture for a table at the same time
我想在同一个 table 中为 SQL Server 2017 (v14.0.3030.27) 添加更改跟踪和更改数据捕获。当我启用更改跟踪时,它工作正常,当我启用更改数据捕获时,它也运行良好。
但是当我在同一个 table 中同时启用两者时,我没有获得更改数据捕获的值。看不到任何文档这么说。
我的计划是使用变更跟踪拉取变更并从变更数据捕获中获取详细信息 table。有什么想法吗?
鉴于您的额外信息 "But my aim is to poll a small table every minute (if possible seconds)",我建议使用 SqlDependency
在数据更改时收到通知,而不是连续轮询。
SqlDependency is ideal for caching scenarios, where your ASP.NET
application or middle-tier service needs to keep certain information
cached in memory. SqlDependency allows you to receive notifications
when the original data in the database changes so that the cache can
be refreshed.
To set up a dependency, you need to associate a SqlDependency object
to one or more SqlCommand objects. To receive notifications, you need
to subscribe to the OnChange event. For more information about the
requirements for creating queries for notifications, see Working with
Query Notifications.
注意事项:
SqlDependency was designed to be used in ASP.NET or middle-tier
services where there is a relatively small number of servers having
dependencies active against the database. It was not designed for use
in client applications, where hundreds or thousands of client
computers would have SqlDependency objects set up for a single
database server.
我想在同一个 table 中为 SQL Server 2017 (v14.0.3030.27) 添加更改跟踪和更改数据捕获。当我启用更改跟踪时,它工作正常,当我启用更改数据捕获时,它也运行良好。
但是当我在同一个 table 中同时启用两者时,我没有获得更改数据捕获的值。看不到任何文档这么说。
我的计划是使用变更跟踪拉取变更并从变更数据捕获中获取详细信息 table。有什么想法吗?
鉴于您的额外信息 "But my aim is to poll a small table every minute (if possible seconds)",我建议使用 SqlDependency
在数据更改时收到通知,而不是连续轮询。
SqlDependency is ideal for caching scenarios, where your ASP.NET application or middle-tier service needs to keep certain information cached in memory. SqlDependency allows you to receive notifications when the original data in the database changes so that the cache can be refreshed.
To set up a dependency, you need to associate a SqlDependency object to one or more SqlCommand objects. To receive notifications, you need to subscribe to the OnChange event. For more information about the requirements for creating queries for notifications, see Working with Query Notifications.
注意事项:
SqlDependency was designed to be used in ASP.NET or middle-tier services where there is a relatively small number of servers having dependencies active against the database. It was not designed for use in client applications, where hundreds or thousands of client computers would have SqlDependency objects set up for a single database server.