如果值为true则不接受数据的约束(1)

时间:2014-09-03 01:15:20

标签: sql sql-server sql-server-2008-r2 constraints

如果IsSuccess = 1已存在UpdateID行,我怎么能创建一个不接受行的表?

Create table myTable
(
UpdateID int,
IsSuccess bit,
)

UpdateID   IsSuccess
--------   ---------
1          0      -- sucesss
1          0      -- success, There is no row for UpdateID = 1 where IsSuccess = 1
1          0      -- success, There is no row for UpdateID = 1 where IsSuccess = 1
1          1      -- success, There is no row for UpdateID = 1 where IsSuccess = 1
1          1      -- fails, There is row for UpdateID = 1 where IsSuccess = 1
1          0      -- fails, There is row for UpdateID = 1 where IsSuccess = 1
2          0      -- success, There is no row for UpdateID = 2 where IsSuccess = 1
2          1      -- success, There is no row for UpdateID = 2 where IsSuccess = 1
2          0      -- fails, There is row for UpdateID = 2 where IsSuccess = 1
2          1      -- fails, There is row for UpdateID = 2 where IsSuccess = 1

0 个答案:

没有答案