I have the following tables and data. How can I create SP to achieve the following result? Table1 ReqId(PK) desc status(bit) 1 some text 0 2 some text 0 Table2 Id(PK) ReqId(FK) shopId appStatus(bit) sequence (int) CompletionDate 1 1 W 0 1 NULL 2 1 M 0 2 NULL 3 1 C 0 3 NULL 4 2 W 0 1 NULL user provides ReqId = 1, and Id=2 and comletionDate I want to update the appStatus to 1 for the id=2. Before updating the table I want make surethe following 1. Table1.status is not 1 for ReqId 1 and appStatus is 1 for Id 1 2. if a record has less 'sequence' for ReqId 1 then I want to make sure that the less 'sequence' record's appStatus is 1 for ReqId 1. No need to update Table2 if appStatus is 0 for the ReqId 1 3. If the two above condition meets and the record is ready for update, then I want check the user provided date is not less than the previous record's (less sequence record) completion date. Please help.