我正在使用constraint
在 sql server 2008 数据库中强制执行业务规则,
alter table TableName with check
Add check
(
(col1 = 1 and col2 > 0)
or
col1 = 0
)
当我尝试在 Management Studio 中执行插入查询时
update TableName set col1 = 1 where Id = 1; --the col2 =0 so it is not valid according to above constraint
执行后,我收到(1 row(s) affected)
没有任何错误消息的消息!!
但实际上当我检查表中的数据时,它并没有改变(这是正确的操作)。
1 row(s) affected
编辑:所以虽然没有影响行,但执行异常行为......