0

How could I create a table that would not accept a row if there already exists a row with IsSuccess = 1 for that 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
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Karlx Swanovski
  • 2,869
  • 9
  • 34
  • 67

0 Answers0