I have two tables: Table A and Table B
RowId
column. ModifiedAt
col
DECLARE @RowId INT
DECLARE CurRowId CURSOR FOR SELECT RowId FROM Patients
OPEN CurRowId
FETCH NEXT FROM CurRowId INTO @RowId
WHILE @@FETCH_STATUS = 0
BEGIN
if not exists (select * from dbo.ResultsStored where ModifiedAt >
(select ModifiedAt from dbo.Patients where RowId =
@RowId))
begin
print'not exists'
end
else
begin
print 'exists'
END
FETCH NEXT FROM CurRowId INTO @RowId
END