在我的 Sql Server 2012 数据库中有下表
CREATE TABLE [dbo].[HumanResource](
[ID] [int] IDENTITY(1,1) NOT NULL,
[Name] [nvarchar](50) NOT NULL,
[IsHired] [bit] NULL,
[Address] [nvarchar](max) NULL,
[Score] [bigint] NULL,
[LastUpdate] [datetime] NULL,
CONSTRAINT [PK_HumanResource] PRIMARY KEY CLUSTERED
(
[ID] ASC
)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
当我更新地址字段(nvarchar,不是 null)时,它被捕获如下
NULL 3 2 mahmood True here 111 2014-09-01 14:42:28.913
NULL 4 2 mahmood True there 111 2014-09-01 14:42:28.913
但是当我更新 Score 字段 (nvarchar, null ) 时,它被捕获
NULL 3 2 mahmood True NULL 111 2014-09-01 14:42:28.913 NULL
4 2 Mahmood True 111 2014-09-01 14:42:28.913
**编辑(更新和选择查询):
update HumanResource set Address = 'blah blah blah' where id = 2
update HumanResource set Score = Score + 1 where id = 2
SELECT TOP (10000) __$start_lsn, __$end_lsn, __$seqval, __$operation,
__$update_mask, ID, Name, IsHired, Address, Score, LastUpdate
FROM cdc.dbo_HumanResource_CT
考虑到 sql server 更新是一个链式删除和插入,第一行是删除行捕获,第二行是插入行捕获。
但我不明白为什么当我更新其他字段时地址被跟踪为 NULL,我将不胜感激有关此问题的任何信息。