In my RequestLog table, i will get multiple request ids, with different executionid.
i want to update SAPSOURCE Table 'Requestid" column where requestid in ("Reqestlog-requestid") and ExecutionID <> ("Reqestlog-executionid")
DECLARE @varRequestId NVARCHAR(255);
DECLARE @varExecutionId NVARCHAR(255);
select @varRequestId = RequestID , @varExecutionId = _AuditCreatedExecutionId from STA.RequestLog where Source = 'SAPSOURCE' and cast(_AuditCreatedDate as date) = cast(getdate() as date)
UPDATE STA.SAPSOURCE set RequestID = 0 where RequestID in (@varRequestId) and _AuditCreatedExecutionID <> @varExecutionId
the reason is there are records duplicated in the SAPSOURCE Table, where the _AuditCreatedExecutionId is not found in RequestLog Table.