I have created the Trigger for UPDATING to be invoked when Returnedon column is updated using the following code snnipet.
CREATE TRIGGER trg_ForUpdateOnBookIssuedDetails on BOOKISSUEDDETAILS For update as begin declare @Rows1 int,@Rows2 int if(update(ReturnedOn)) begin begin tran update nur set nur.NumberOfBooksIssued = nur.NumberOfBooksIssued -1 from NewUserRegister nur inner join INSERTED i on i.IssuedTo=nur.UserName set @Rows1 = @@RowCount update lbd set Inventory = Inventory +1 from LIBRARYBOOKDETAILS lbd inner join inserted i on lbd.BookID = i.BookId set @Rows2 = @@rowcount if @Rows1 * @rows2 >0 commit tran else begin raiserror('Error Updating the Database',16,-1) rollback tran end end end
Now I want To perform this Updation only if the RETURNEDON column is null. If the ReturnedOn column consists of some other value then the Updation of records should not take place.
Can anyone help me out in performing this task?
Please help me out.
Thanks in advance!!